Posts by Isac • 24,736 points
820 posts
-
4
votes2
answers51
viewsA: How do I point (with pointer, of course) to a string, so I can then print it?
If you want to point to a string (array of characters) with a pointer, just do: ponteiro = string; So in your code the assignments: * p = nome; * p = outronome; They’re not right. Remember that *p…
-
3
votes1
answer60
viewsA: How to add a character in a string, which is already divided, to each N characters?
To make the missing part can use a regex, which would be the most direct. The regex would be: /.{1,6}/g Any character (meaning of .) quantity 1 to 6, applied globally (g). When used with match will…
-
7
votes2
answers1502
viewsA: Is there a more optimized way to "multiply" a string without using repetition?
Yes, you can use the method repeat of string, which takes as a parameter the amount of times to repeat. Take the example: var str = "palavra "; console.log(str.repeat(5)); As indicated by the friend…
-
1
votes1
answer533
viewsA: How to use Foreach in a multidimensional array in PHP
A multidimensional array would normally be traversed with a double foreach. In your case with: foreach ($Marcas as $subMarcas){ foreach ($subMarcas as $marca){ //código aqui } } However I got the…
-
1
votes1
answer8098
viewsA: Stack error Smashing Detected in C
Error indicates you are crossing matrix boundaries, and write to memory zones that cross boundaries. This happens in the for building the second matrix: if (matriz[i][j] <= 30) { if (matriz[i][j]…
-
3
votes1
answer70
viewsA: Inversion of each line of a C file
Its inversion of the string is too complex: while((size_t)i<strlen(line)){ for (i=0 ; (line[i]!='\0') ; i++){ for (j=0; j<i; j++){ char tmp = line[j]; line[j] = line[size-1-j]; line[size-1-j]…
-
2
votes2
answers225
viewsA: How to group a list in javascript and calculate subtotals?
Another simple solution is to use a for normal to walk through each person, and realize if the person already exists in the array grouped through findIndex. If there is no add the new person,…
javascriptanswered Isac 24,736 -
1
votes1
answer992
viewsA: Insertion at the end of a chained list C
You only need to use one while to pass us until we reach the last. The last is the one that has the ->prox to NULL. Thus: ... else{ No* atual = Lista->prim; //começar no primeiro while…
-
2
votes2
answers49
viewsA: Filter elements by the highest attribute
Solution with sort and filter A very compact solution is to use sort to sort all values by name and y, getting the bigger ones y first. Then uses filter to filter so that whenever it picks up an…
javascriptanswered Isac 24,736 -
5
votes2
answers895
viewsA: Output error - C language
The problem has to do with the interim gets and scanf, and in this case the gets is only reading the line break left from the c.idade leaving the text unread, which is caught up by the following…
-
1
votes1
answer26
viewsA: Javascript does not list elements
What doesn’t let your code run is even a typo in: var chaves = object.keys(this); // ^---- Deveria ser Object But interestingly you’re not using the variable chaves in the code that follows so it…
-
1
votes1
answer47
viewsA: Iterate an array to the end from a randomly generated index - PHP/Laravel
To select the stop where you will start just use the rand(that you were already using) 0 to the length of the stops minus one, which will give you the starting position: $indiceParadaInicial =…
-
2
votes1
answer618
viewsA: Syntaxerror: Unexpected token: string literal -Javascript
Missing one + in concatenation: var parms = "&cpf="+cpf"&conta="+numConta; //O ERRO É APONTADO NESTA LINHA // ^---aqui I couldn’t find anything in Stack to help me This is normal, because…
javascriptanswered Isac 24,736 -
3
votes1
answer106
viewsA: Difference between dates with condition (only count given month)
A date in Excel, also called the serial number, is the number of days that passes from 01-01-1900. So subtracting two dates and showing the formatted result as General or Number already gives you…
-
2
votes1
answer343
viewsA: Dictionary for objects in Python
I start by saying that for elemento in len(range(iteravel)) is always the wrong way to iterate in python. The correct is to use for elemento in iteravel, or in cases that need the Dice can use the…
-
1
votes2
answers37
viewsA: How to add Divs from a past Select number?
It already has an answer that suits it in terms of solution, but it is always important to realize our mistakes so that we can evolve and not commit them in the future. This is your Javascript code:…
-
2
votes2
answers3641
viewsA: Include quotes in variable value String
The way to include double quotes as text in a String in Visual Basic is putting two in a row, so "". Your example code should become: Public frase As String = "E ele disse: -""Olá a todos!""" See…
-
2
votes2
answers74
viewsA: exclude people names from a C array
Your code some mistakes and confusions. nome[i]100] = nome[i+1][100]; - here lacked a [ so that the syntax was right, but I suspect that this was lost when building the question here ? Anyway, each…
-
2
votes2
answers912
viewsA: Box with edge and a heading on top edge
The label <fieldset> allows you to create this box with contour around it, and the label <legend> inside defines what appears at the top as "title". Take the example: /* estilos apenas…
-
2
votes2
answers104
viewsA: How to pass structure data to a text file?
One easy way to control how data is written to the file is to use fprintf. This is identical to the printf except that the first parameter is where the information will be written to. Example: FILE…
-
1
votes3
answers1105
viewsA: Reading Struct Strings with Wrong Scanf
I would like to begin by reiterating what I have already said: It is worth remembering that scanf("%s reads only one word, leaving the rest in the input stream. If you want to read an entire line,…
-
0
votes1
answer39
viewsA: buffer is not cleaned during the second execution of cilclo
Although the definition does not specify fflush for a stream incoming as the stdin, some compilers support this, which makes your problem in such cases can be solved by swapping setbuf(stdin,NULL);…
-
0
votes1
answer574
viewsA: Show Password entered in two fields by clicking only one icon
To show the password in both at the same time just need to grab the new field, and apply the type of the first: var tipo2 = document.getElementById("inputPassword2"); tipo2.type = tipo.type;…
-
1
votes1
answer865
viewsA: Method to Invert a Single Chained List
A simple way to do this without using auxiliary structures or switching to a double-linked list is with recursion. You can open each next knot until you reach the end, the NULL and before finishing…
-
0
votes7
answers1690
viewsA: Hexadecimal for RGB
In Java Using the class Color of java.awt just do: Color color = Color.decode("#FFFFFF"); That gets the color corresponding to the value in hexadecimal. Then it is possible to obtain each RGB…
-
1
votes1
answer275
viewsA: How to put classes inside vector and manipulate variables with push_back?
The most direct without changing anything would be: std::vector<x> teste; x obj1; //criar o objeto obj1.var1 = 10; obj1.var2 = 20; teste.push_back(obj1); //adicionar ao vetor com push_back…
-
5
votes4
answers725
viewsA: Function that returns the element with more characters from a list
The other answers already feature fixed/working code, and interesting alternatives, but do not detail the problem, which is important to be able to prevent/correct similar future errors. Note the…
-
5
votes3
answers1906
viewsA: Decimal to octal conversion
The code you have does not use the variable octal which is the one you use to return the calculated value, so you will always give the random value you pick up in memory, unless you enter the first…
-
1
votes1
answer663
viewsA: Fibonacci in JS with arrays
The calculation of the numbers is correct but the way you’re presenting them is that: alert("Posição = " + i + ".\nValor = " + n[i]); Is showing the i as position, that when the for is already one…
javascriptanswered Isac 24,736 -
4
votes1
answer1363
viewsA: Pass data from a struct within the function
The most normal would be to pass a pointer to the structure you want to access in the function, and in many cases it will be more efficient because it avoids copying content unnecessarily. The…
-
1
votes1
answer256
viewsA: how to remove object from the lodash array
First of all, you’re comparing objects with ==, that doesn’t work the way you’re thinking. Look at this little example: seat = { x:1, y:2 }; selectedSeats = [{ x:1, y:1 }, { x:1, y:2 }];…
javascriptanswered Isac 24,736 -
4
votes2
answers113
viewsA: Qsort ordering in the wrong way
Your problem is actually quite typical in the qsort, which is to forget that the comparison function receives pointers to the array values. So if you have an array of ints the comparison function…
-
3
votes1
answer319
viewsA: Do not accept duplicate values in a Regular Expression (Regex)
You can use the following regex: ([0-9]{9})(?!.*\1) See working on regex101 Explanation: ( - primeiro grupo de captura [0-9]{9} - 9 digitos de 0 a 9 ) - fecha o grupo de captura (?! - Negative…
-
2
votes3
answers7818
viewsA: Read multiple scanf numbers separated by space
If you want to read several separate numbers of space, then you want to read it all as one string and basically make split on a certain separator, in this case the space. The easiest and native way…
-
0
votes1
answer51
viewsA: Segmentation Fault
As already indicated the correct is to use realloc, that you can go asking for the elements of the form you are already asking for, and increasing the size of the vector as it receives elements.…
-
2
votes1
answer65
views -
4
votes2
answers80
viewsA: How to translate this if javascript to PHP?
In PHP, a solution would be like this: if ($telefone == str_repeat($n, 11) || $telefone == str_repeat($n, 12)){ return false; } Explanation This test you have in the code is a little strange and…
-
2
votes2
answers139
viewsA: Code problem in Java
The problem is here: player.setNome(entrada.nextLine()); entrada.nextLine(); You actually reversed the instructions. The first nextLine is that it only picks up the last line left of the last…
-
1
votes1
answer32
viewsA: The system is not reading the requested line
The problem is in \n the most in readings with scanf: printf("%s", "Insira o dia: " ); scanf("%d\n", &diatemp); // ^-- aqui printf("%s\n","Insira o mes: " ); scanf("%d\n", &mestemp); // ^--…
-
1
votes1
answer54
viewsA: Generate a sentence list sorted by the js arraySort()
You are making one sort within another sort: function arraySort( a, b ){ lista.sort( ); // ^---- e dentro da função de ordenação chama sort de novo } var retorno = lista.sort( arraySort ); // ^---…
-
2
votes4
answers71
viewsA: Repeat zebra style color only 5 by 5
What the code does is it turns red if the position is multiple of 5 and blue otherwise. To make the exchange of 5 in 5 can define an initial color, and at each multiple position of 5 change the…
-
1
votes2
answers215
viewsA: Get the value of a radio type button with Vanilla Javascript?
The function getElementsByName return a NodeList, which is like an array of elements with that name. This makes you have to access the first one at the position 0 or alternatively use a loop/loop to…
-
4
votes2
answers133
viewsA: How to filter a Hashmap by returning another Hashmap using Java 8 lambda?
If you want to filter those that are active with stream and filter, only need to use the method isActive within the filter and accumulate the result in a set with toSet:…
-
6
votes1
answer104
viewsA: Difference between [i] + 1 and [i + 1]
I have doubts about [i] + 1 and [i + 1], one increases position and the other content, correct? Actually the first, the [i] +1, returns what is at the summed position of 1. Whereas the second, the…
-
1
votes2
answers2198
views -
3
votes1
answer89
viewsA: Array bug when passing size 4
There are two subtle errors in the code: int i, j, x=0; int vetor[x]; Notice that vetor is created with size 0 for the x is 0 at the time of its declaration, causing any access to vetor results in…
-
3
votes1
answer70
viewsA: Search string snippets
As its name implies startsWith says whether the String begins with certain text. To know contain the text anywhere and not specifically at the beginning use contains: String query = "Policia…
-
3
votes2
answers56
viewsA: When selecting an option, the color of the selected option is marked
You can get the style of the selected option with attr for the attribute style and applies it to select. To get the selected you can use find(":selected"). Example:…
-
1
votes1
answer1144
viewsA: create print button for each table
Let me start by saying that you can control what you print on a CSS-only page by hiding the elements you don’t want to appear. This is done either with the @media print on the page in question, in…
-
1
votes1
answer46
viewsA: How do I print on the screen the equal values of two integer vectors?
If you have the assurance that the vectors are ordered you can use the following logic: Start at first position in each of them. At each step compare both values of each If the A minor advances only…