Posts by Isac • 24,736 points
820 posts
-
3
votes3
answers117
viewsA: Text looks full of junk after typed
Problem This problem is very common for those who are starting or are not very much on the subject, and is related to the form with the scanf with %d works. If you repair the scanf with %d does not…
-
3
votes4
answers246
viewsA: How do I organize each position on my list in ascending order?
As a complement to what has already been said, it can also do the sort it wants using list compreehension that stays in a line: a = [sorted(lista) for lista in a] print(a) # [[1, 2, 3], [2, 3, 4],…
-
1
votes2
answers181
viewsA: Values returned in comparison of strings in C
The @Maniero already said basically everything there was to say, but I take the opportunity to put the table of returns that is in the documentation that you linked (translated by me):…
-
2
votes3
answers95
viewsA: More or less a Select in array
Another way that most values performance is: Create an auxiliary array based on array2 use the cpf as key for the research to be done in Central time, O(1). Traverse each element of array1 and if…
-
4
votes3
answers478
viewsA: .is() jQuery - how does it work?
The is Jquery is used to check whether the selected element corresponds to a particular element. This function can be called by passing different parameters: Selector Object Function Passing a dial…
-
10
votes5
answers6866
viewsA: Indicate whether a character is a vowel or a consonant
Problems The returns you have are not right: return true ... return false True and False take the first letter uppercase. As has gives error of execution because neither true nor false exist. This…
-
8
votes3
answers816
viewsA: Remove spaces from a string from the second occurrence
Using only replace can also be done, although it probably does not compensate for performance/readability/support. You can use the following regex: (?<=\s.*)\s+ Explanation: (?<= - Positive…
-
5
votes1
answer93
viewsA: Why can’t I print it?
Turns out you didn’t initialize the pointers. As the name itself indicates, they are pointers, so have to point to some place in memory that is where the values are placed. Just when it does: *area…
-
0
votes1
answer56
viewsA: Segmentation fault while reading file
There are some errors in your code. My advice is when you’re coding, take your time and make sure what you did back there feels right, and go testing, rather than writing all the code and testing at…
-
2
votes3
answers497
viewsA: Char pointer in printf() does not work
@Maniero has already indicated to you the various mistakes you had, but I think it is important to mention that you should always be aware of what you are trying to do, because in many cases there…
-
1
votes4
answers181
viewsA: Complete numbers with Javascript
The action of completing with a certain character until making a size is often called pad. Javascript already has functions to do pad both on the left and on the right, they being the padStart and…
javascriptanswered Isac 24,736 -
2
votes2
answers900
viewsA: How can I export output to a C text file?
To redirect the output of a program to a file just call the right way from the terminal/command line: Windows: programa.exe > arquivo.txt Unix ./programa > arquivo.txt Analogously can use <…
-
0
votes2
answers470
viewsA: Match Checking Python Hangman game
If the word the player has to hit is the variable palavra, and you keep the letters that he hit the list riscos then you can compare the palavra with the conversion into string of lista using the…
-
1
votes2
answers141
viewsA: Is it recommended to use memset before strncpy?
The documentation of strncpy answers your question. Citing only the parts that matter: If the end of the source C string (...) is found before num characters have been copied, Destination is Padded…
-
2
votes4
answers1088
viewsA: Add Word Links to a Text
A solution is: divide text into words with split take all words and turn into a link with map put everything back together with join apply the new text as html in the right place Example: function…
-
4
votes2
answers209
viewsA: Why isn’t the break working?
The break forever only the inside loop. Soon analyzing your code: for (c=0; c<TAM; c++){ aux = false; for (c2=0; c2<TAM; c2++){ // este é o loop que para if (matriz[c][c2] == num){ p1 = c; p2…
-
1
votes2
answers922
viewsA: Keep Hover on a button after taking the mouse out
The problem has already been explained in the other answer, which suggests you change the event click for mouseover. If you want something to happen when you pass the mouse then it really has to be…
-
3
votes3
answers840
viewsA: Replace word list in text
For the sake of clarity, and also because the solution you put forward was not quite as I had suggested, I leave here my suggestion. The suggestion was to apply a regex to the whole text, which…
-
5
votes3
answers3857
viewsA: Catch the last occurrence in a javascript string
Just to give one more chance, you can also do it with a simple regex. This does not mean that it is better than the already good alternatives shown, and will probably be less efficient too. The…
javascriptanswered Isac 24,736 -
1
votes1
answer414
viewsA: Prompt Javascript
The problem is that you are not visualizing the string which will be interpreted by parseInt. A input of 12 in the prompt it’ll be like I wrote: let texto = "12"; But a input of "12" it’s like I…
javascriptanswered Isac 24,736 -
2
votes3
answers5398
viewsA: Count number of times letters repeat in a text
The most direct and advised way is to use what already exists, the Counter, as @Andersoncarloswoss has already indicated. However, by taking your algorithm, you can manually do what you want without…
-
1
votes1
answer120
views -
1
votes1
answer63
viewsA: How to make a progress bar that goes from 0 to 70 and doesn’t come back from the beginning?
What makes it repeat is Animation-iteration-Count which left the infinite: animation: site 5s infinite ease-in-out; /* ^---- este */ This indicates how many times the animation repeats, and…
-
1
votes1
answer668
viewsA: Create a file in another directory
The function fopen has to receive the string with the path, and you are to pass ("Arquivos//%s", nomeDoArquivo), that is not valid. Beyond that / is not a character that needs to escape and so does…
-
1
votes1
answer1497
views -
3
votes1
answer1282
viewsA: Function javascript sorting in descending order
To make the order decreasing just change the order of the comparison, changing the b for a at the place of comparison: ordenaNomeCompleto: function(a,b){ var ans =…
javascriptanswered Isac 24,736 -
1
votes1
answer44
viewsA: Select using an array?
Since the values you’re using for the IN are texts (varchar) they have to come in quotes, each individually, which is not what happens at the time for their variable sql. See for yourself: var…
-
4
votes2
answers51
viewsA: How to modify the last item of a sequence in Java?
A very simple way to solve it is with a condition within the for, which writes the element followed by: Space if not the last ! if it’s the last Example: for(i = 0; i < N; i++){…
-
1
votes2
answers357
viewsA: Concatenating the elements of an array
Another interesting way to solve the problem is to build a new result array with the transformation you want. This can be done at the expense of push, that simplifies the problem. You can do push of…
-
4
votes2
answers133
viewsA: how to print a list of numbers with an interspersed sum?
If you already have the list built, and want to apply a sum, jumping from x in x elements, just a for with an increment of x in x that stops when it reaches the number of items on the list: int…
-
2
votes1
answer4180
viewsA: Import functions from another file (Node.js)
Can always do require of the file in question to be able to use what it has, provided that it has made the necessary exports in it. In the Somar.js could make the whole function export, using…
-
3
votes2
answers490
viewsA: Callbacks in Javascript
Callback or Callback Function is the function that is passed to another function, and that will be called later when needed. Confirm the definition of Callback Function on MDN So in your example,…
-
8
votes2
answers58
viewsA: How can I create a regular expression that accepts a certain number at most once
Just to give one more alternative, also to solve with a regex using Positive Lookahead: 2(?=.*2) Explanation 2 - Procura pelo 2 (?= - Que tenha à frente .* - Qualquer coisa 2) - E outro dois This…
-
1
votes1
answer570
viewsA: How to identify end of C++ entries using Cin
When a reading is not possible cin is marked as invalid, which when rated as boolean will turn out to be false. This allows you to do things like: if (cin >> x){ } That will only enter the if…
-
5
votes5
answers7817
viewsA: Sum of each element of two lists
The most direct solution is to use the native function zip which allows the joining/merging of two rolling stages. zip(iteravel1, iteravel2) The result is an object that when iterated functions as a…
-
6
votes5
answers1540
viewsA: Check that all $_POST was shipped without using too many ifs
You can simplify the logic considerably if you use an auxiliary array for the fields you are interested in. In this case you can iterate the fields with a foreach and test whether each is defined in…
-
6
votes1
answer263
viewsA: How do I pass the first char address of a string to a function to write to it?
In fact the code you have is very close to working, needing only a few adjustments. You are already passing the address of string for the function SystemGetOut_char: SystemGetOut_char(command,…
-
3
votes3
answers443
viewsA: Get Integer value in final . 00 and float value in . 01 to 0.9
A simple way to see if the result has decimal part or not is to compare it with the conversion of the value into integer. That is to say if 2.5 has no decimal part would do 2.5 == (int)2.5 that…
-
3
votes4
answers320
viewsA: Check if a string is only composed of 0
Since you already have answers with regular expressions, I show you an alternative without regular expressions, although it is not so compact. The idea is to test with another string built with…
javascriptanswered Isac 24,736 -
0
votes1
answer233
viewsA: Organize array
Personally I advise you to use the loop really normal and do what you have to do that is simpler to read, generating a less complex solution. There are many other scenarios that would be advisable…
-
3
votes1
answer424
viewsA: Discover string inside string without string library. h?
In its implementation it has the logic that goes through the letters of the main sentence, but the logic that sees if each letter is equal to the letters of the second string is missing. Trying to…
-
1
votes1
answer40
viewsA: PHP min($footage) bringing the wrong value
Its values are strings, so the result you get is the minimum of an alphabetic ordering, which would be even the 111,5. To get the minimum in numerical terms you have to convert each value into…
-
2
votes1
answer1897
viewsA: Split the program with libraries . c and . h
To divide into .c and .h simply create a role in the .h, and in the .c put all the code you have. Then it would only be necessary to call on main. That wouldn’t be a great idea but it would look…
-
6
votes2
answers3768
viewsA: What is the equivalent of PHP explode in Python?
split is the equivalent of explode of PHP, which is a method of string. In fact almost every language in which this functionality exists is called split, PHP being the only (or almost) that gave it…
-
0
votes1
answer36
viewsA: Variable returning 0 in file
There are two situations that need to pay attention to your code: You are reading and writing the array multiple times in fors: for(i=0;i<3;i++) { ... fwrite(&num1[i],sizeof(num1[i]),100,fp);…
-
0
votes3
answers396
viewsA: Odd Number Calculation - Javascript
Expanding a little bit on the solution you put as EDIT, to divide 100 in several equal instalments does not need to for. In any case, there are several cases where it will not be possible to have…
javascriptanswered Isac 24,736 -
4
votes3
answers107
viewsA: Help with string programming logic?
There are several small errors in your program: The if to show the result is switched: if(chave==0) printf("O caractere informado existe na string.\n"); else printf("O caractere informado nao existe…
-
3
votes2
answers573
viewsA: How to access an object by a variable?
I personally suggest another approach to the problem. If it is you who controls the objects then you can encode them differently in order to make the code more useful, like this: var opcoes = {…
-
1
votes1
answer52
viewsA: Sorting an unordered list does not work
There’s a lot of things you need to get right for the addition to work. Its function Ordenar doesn’t even advance through us: Lista*nvlista=CriandoLista(); while(lista->Inicio!=NULL){…
-
1
votes1
answer222
viewsA: Group, assign, and sort values from a multidimensional array in PHP
The easiest way to solve your problem is to create an array with the counts of each element and then sort based on the counts. For the creation of counts, you can create an empty array and add up…