Posts by Isac • 24,736 points
820 posts
-
1
votes1
answer119
viewsA: Storing multi-button status on localStorage
As I suggested in comment, the best is to keep the state of everything in localStorage, as an array of elements. For what you want to do just save an array with the class to apply to each button,…
-
1
votes2
answers81
viewsA: How to make the same event work several times in different elements?
Just to leave it here as a reference, you can do what you want without using javascript, at least for the example you have in the question. Repair gives the style when you click (ie when you win…
-
1
votes1
answer47
viewsA: Adjust vector post element removal
Its code does what is intended, to pull all the elements one position back although it is more complicated than would be necessary. Now remember that what you actually did is copy all the…
-
0
votes3
answers41
viewsA: Sidebar open at the place I click?
The point is that you click on a link, which itself already has an implicit navigation, in the case to #, so the page goes up to the top. What you need to do is cancel this navigation, one of…
-
2
votes1
answer67
viewsA: Pause setTimeout() function when hovering the mouse
As has already been said, there is no possibility to pause a setTimeout or even a setInterval. But you can change your code to "give that idea". In your case it is a little more work because you…
-
0
votes1
answer29
viewsA: Problem when creating Multidimensional Array with Jquery
Personally I think that your approach has become a little complicated, and I prefer to show another way to solve it, by a simpler way. I started by creating a function that tests if a property…
-
2
votes2
answers94
viewsA: How to erase the symbols of a CPF in an input?
I suggest a more elaborate solution, but more robust and flexible, that does not cause you problems when deleting a number just getting the trace at the end, or when you have just deleted the trace…
javascriptanswered Isac 24,736 -
3
votes5
answers1315
viewsA: Join two events that have the same function
I know the question doesn’t have the Jquery tag, but I’ll answer it anyway because I think it’s useful information. Through Jquery you can record multiple events for the same code with the function…
-
0
votes3
answers358
viewsA: JS: store selected values in array
It is better than seeing if you have drawn repeated and draw again is using a different algorithm, like the Fisher-Yates that randomizes the array, and then you just take elements from the…
-
4
votes1
answer99
viewsA: Count of arrays inside an object!
You just need to use a loop that goes through all the properties that exist in the object, and add the associated arrays sizes. Thus: let items = { 0: [ { foo: 'foo' }, { bar: 'bar' }, ], // length…
-
0
votes2
answers108
viewsA: Help in python Lists
The test you did makes no sense: if lista[n][0]==lista[n][0]: This condition checks whether the element is equal to itself, which it will always be. When it if lista[n][0]!=lista[n+1][0]: You’re…
-
1
votes2
answers95
viewsA: Mergesort sorting algorithm error
Whenever you see random values should distrust: ordered vector [ 1 2 3 5 7 7 8 9 6422300 ] ^^^^^^ Most of the time it means that you’re accessing parts of the memory that you shouldn’t and so it…
-
0
votes1
answer210
viewsA: function to insert a no in a linked list in C
The code for the missing lines is as follows: int insere(char * nome, int idade, struct lista ** primeiro) { struct lista * no = malloc(sizeof(struct lista)), *atual = *primeiro, *ant = NULL; if (no…
-
1
votes2
answers86
viewsA: String problem in C, term exclusion in string, through string comparison
There are several problems in your code and things you are not using, but before you indicate them, I start by presenting a solution following more or less your logic: #include <stdio.h>…
-
2
votes3
answers751
viewsA: Compress array by removing zeros [C]
It already has some answers with alternative solutions to the question it intends to solve, but it is always good to understand where we went wrong and what does not serve our goal. This is where my…
-
1
votes1
answer41
viewsA: How to place an increment inside a FOR loop?
The problem in your solution is that the variable j was created within the if which only exists in the if and cannot be used elsewhere. In addition to doing int j = j + 1; causes the variable to…
-
1
votes2
answers78
viewsA: Animate script that changes the "src=" of an image
I want to leave here as a reference a way to do it using javascript only. Of course it is not as simple as jQuery (as it has in the answer of user140828), but it’s also nothing out of this world. I…
-
2
votes3
answers111
views -
1
votes3
answers534
viewsA: Escada Javascript
Also can solve using only the repeat you already have in your code. The idea is to first write a certain amount of spaces and then join with a number of # that makes sense for the line on which it…
javascriptanswered Isac 24,736 -
1
votes2
answers380
viewsA: Return of system(); c++
Just to clarify a little bit about the function system, because the use you have shown is not correct: string hostname = system("whoami"); The function system executes a given command but does not…
-
1
votes1
answer137
viewsA: Increment pointer inside C-linked list
(...) my goal is to have a multi-stroke pointer within each linked list node A pointer only tip to a memory zone, which leads to the first problem: Who defined this memory zone and put the values…
-
3
votes2
answers31
viewsA: index() only for elements with a specific class
The method index in Jquery allows you to pass a selector that refers to the elements you are interested in. So in your example you just have to do so: $(".index").index(".x") Which means to get the…
-
2
votes2
answers439
viewsA: While() read by line in file . CSV
Starting with your questions: What is the best function to read lines from a CSV file Each case is a case and always depends on the structure your data has, validations that have to be applied,…
-
0
votes1
answer83
views -
14
votes4
answers349
viewsA: How to make an element cross the screen continuously and always visible?
One way to do it is to put as after an equal element on the right by the entire screen size with left: 100vw. So when the element starts to disappear on the left the distance to the right appears in…
-
2
votes1
answer70
viewsA: "format specifies type" error, C language
The warning tells you that the read formatter is char* which come from the %s, but the place where you’re holding the value is a struct crPlayList *, soon it will not work as expected as they are…
-
2
votes1
answer55
viewsA: Doubt regarding string manipulation
You have several small errors in the code, some of which do not allow you to compile and others are shown only as warnings. int main( int, char ** ) - Each of the parameters of the main and the most…
-
1
votes2
answers1132
viewsA: Change compiler settings in Codeblocks
GCC and G++ versions are independent of Codeblocks, which is only the IDE. To have updated versions of the compilers you need to install them by downloading the original websites. In windows the…
-
2
votes2
answers65
viewsA: How to identify acronyms with Regex Javascript
The regex you are looking for is: ^P[a-zA-Z0-9]{2}$ Meaning: ^ - Inicio da linha P - A letra P maiúscula [a-zA-Z0-9]{2} - Uma letra ou um digito duas vezes $ - Fim da linha Example in JS: const…
-
1
votes1
answer621
viewsA: Void pointer in C
The code you wrote does some things that make no sense. Note for example this line: x1 = (int *)malloc((i1 * sizeof(int))); Here creates space for as many integers as the number that is in i1. It…
-
0
votes1
answer36
viewsA: Add initial value to a linked list
Missing return in node creation function: NODE * new_node (int v, NODE *prox) { NODE *l= (NODE*)malloc(sizeof(NODE)); VALUE(l)= v; NXT(l) = prox; return l; //<-- este } And in the main missing to…
-
4
votes2
answers211
viewsA: Select next elements
As explained above, the <input> where the code breaks, there are no brothers, and he’s alone in the <td>, soon enough next, as nextAll or find can’t find anything. You need to go first…
-
1
votes2
answers215
viewsA: Why can’t I pass a matrix as a parameter of a function in C?
@Kahler already explained the problem, which is to have an incorrect size in the function parameter, but my answer shows how to solve leaving the dynamic size. If you try to put matriz[dim][dim]…
-
1
votes1
answer66
viewsA: textarea does not accept </script> as text
This is a very particular case of the text being put on textarea. Notice that when you try to put the </script> doesn’t work: document.getElementById("id_textarea").value="</script>";…
-
0
votes1
answer957
viewsA: Doubt in exercise in C - reading with fgets
The two problems are actually the same, which is the fact of the fgets leave the line break in the read string. For this reason, the if that tests if it has size 0 will never work because it always…
-
3
votes3
answers337
views -
0
votes1
answer22
viewsA: Impossibility to search multiple strings in a file. txt
A practical solution is to store the words of the archive in a map or in a set and then check directly, without having to browse each file line for each check. A map or a set also guarantees you a…
-
1
votes2
answers157
viewsA: Sort an array of strings with dates
If you want to sort by year and then by month alphabetically and keeping the array in the format you have can do so: let datas = ["nov/2018", "set/2018", "jan/2019", "dez/2018", "out/2018"];…
-
1
votes2
answers177
viewsA: List validation with Javascript
The biggest problem is that you always enter the element in the list regardless of the situation: function listaConvidados() { var recebeNome= campoConvidado.value; lista.push(recebeNome); Note that…
javascriptanswered Isac 24,736 -
5
votes2
answers2210
viewsA: How to concatenate a char into a string?
You are confusing letter with text (character with string). In C a letter or a character is defined by type char. A string or text is defined as an array of characters and will normally be written…
-
1
votes1
answer111
viewsA: How to relate 2 arrays (array1 is name and array2 is ID) and bring the corresponding value
You have the function array_combine php combining one array with another causing the first array to be the keys and the second the values. For your code to associate the two things allows you to…
-
2
votes1
answer56
viewsA: Question about address in the pointer mémoria
Starting with the first statement you made: and to my surprise the address shown repeated several times This is expected for the code you have, the insertRight, 'cause every time you’re about to…
-
3
votes1
answer109
viewsA: What’s wrong with my code?
There are a lot of things wrong, but let’s start with the things that make your program work. Its function chamar you want to return a string, so you have to return something like char* and not…
-
5
votes3
answers65
viewsA: How to join the score with the last word on the left?
This separation that you see with spaces happens because the print was done by separating each value with comma, ie by invoking print with several values: print("O percentual concluído até o momento…
-
8
votes2
answers1371
viewsA: Regex capturing exactly x digits of a string
You can use the following regex: \b\d{6}\b The \d is the meta character for digit, looking for a digit from 0 to 9. The {6} indicates that you must find 6 of these in a row. The \b indicate that it…
-
1
votes1
answer154
viewsA: Sort from minor to major in priority_queue unpacking by second element, is it possible?
It is possible to control how the elements are placed in a priority_queue if using a custom function in the third template parameter. This function has to be provided via the operator () of a class…
-
3
votes1
answer44
viewsA: How to ignore the last element in recursive call
There are several ways to implement the logic you want. The solution I show you is to invert the logic a little, so that show the first element normally, and each element of the front shows first…
-
5
votes1
answer72
viewsA: Entering an arithmetic expression instead of an integer in C
instead of typing an entire value I put an arithmetic expression and to my surprise it is not that it worked? Giving the result you expect is quite different from working. In the case was mere…
-
1
votes1
answer742
viewsA: Bubblesort - Lexicographic (Alphabetical Order) repeats the first name
To be correct in your code do as follows: void bubbleSort(char (*V)[30], int Fim) { int i, j; char temp[30]; for(i=0; i<Fim; i++) { for(j=0; j<Fim - 1 - i; j++) { if(strcmp(V[j], V[j+1]) >…
-
4
votes1
answer132
viewsA: How to allocate memory space?
The problem that causes your program to show nothing on the console is a ; lost, and more in the wrong place: if (!p); // ^--este { printf("Nao foi possivel alocar o vetor !"); exit(0); This is a…