Posts by Penachia • 506 points
21 posts
-
4
votes1
answer52
viewsA: Pointer
You are copying the student, void adiciona(aluno a, classe *c) { c->alunos[c->n] = &a; c->n++; } so a copy of it is added to alunos but when leaving the scope of the function adiciona…
-
-1
votes2
answers1167
viewsA: Insert an empty space between a concatenation of strings in C, without the string library. h
You can use the function strcat library string. h strcpy (concatNome, nome); // Adiciona a string nome para a string de concatenação strcat (concatNome," "); // Concatena o espaço em branco na…
-
3
votes2
answers65
viewsA: length() giving Nullpointerexception
The right thing would be while(entrada != null && entrada.length() != 0) because case entrada is null will not attempt to execute the function length and shall not enter into the snare which…
-
4
votes2
answers218
viewsA: Destructor in C++
Because when leaving the main scope the object mClasseE dies, thus calling the destructor of its class, which increases and prints, as the value of a was 10 shows 11. Already the object mClasseD…
-
0
votes1
answer64
viewsA: Bubble Sort in C inconsistent
int vetor[TAMANHO],n1,n2,ctr,ctrInt; You must put in the array declaration the number of elements you want and not the last element’s input, ie to have an array with TAMANHO elements you must…
-
1
votes1
answer133
viewsQ: Problem downloading a file with an accented name
I have a function that returns a file to download, when the file name has accented characters and a certain size, the downloaded file comes with the wrong name (in Chrome comes the name of my…
-
2
votes2
answers77
viewsA: How to modify the content of a root using a pointer?
#include <stdio.h> int main() { float raiz = 3.1415; float *aponta_para_raiz; aponta_para_raiz = &raiz; *aponta_para_raiz = 3.141592; printf(" RAIZ = %f\n", raiz ); printf (" RAIZ…
-
0
votes1
answer560
viewsA: how to check a string in if
color is a pointer to an array of chars then when you make the comparison cor == "branco" you are comparing the value of pointers and not the words, to compare the words you can use the function…
-
1
votes1
answer61
viewsA: File import. txt C++
Your problem is in those lines palavra_aux = new char[pal.length()+1]; strcpy(palavra_aux, pal.c_str()); You create the char vector with the string size + 1 and then use the strcpy that instantiates…
-
0
votes2
answers55
viewsA: How to find a comma inside a Textbox
I don’t know if this->textBox1->Text is a Std::string but in case it’s just walking around looking for commas: int contadorDeVirgulas = 0; for(int i = 0; i < str.size(); ++i) { if (str[i]…
-
1
votes1
answer40
viewsA: Error counting repeated values in an array
You are not checking if the number already exists in the vector, if it already exists increment your counter and otherwise add it. bool bNumeroJaExiste = false; for (int j = 0; j < TAM &&…
-
2
votes1
answer374
viewsA: How to add an element at the end of a linked list
You are not adding the items in the end, you are pointing all the new items to the first. You should create a new item and point the last of the list to it, like this: while (cursor->getProx() !=…
-
0
votes3
answers100
viewsA: Printf does not print inside the while
The function inserts does not connect the created objects, ie when at the time of printing you "walk" between the objects l = l -> prox; is not pointing to the instantiated objects in the…
-
0
votes1
answer33
viewsA: I am trying to compare the word deposit with what the user will type, and if it is equal he will make the deposit
You cannot compare a char string with an element enclosed by single quotes, i.e., menu == 'deposito' // deveria ser: menu == "deposito" Here your complete code, I traded the printf for library…
-
1
votes1
answer48
viewsA: Why does multiplying the percentage give negative results?
The return of {cont1 * 100 / 25} is a value float but your printf expects a whole %i, according to the language documentation when the past type is different from the expected behavior is undefined.…
-
1
votes1
answer31
viewsA: Pass parameter to a get method, can it generate an error in C++?
Not, Get is just a name used by convention and means nothing. Your function will return the parameter passed and not the member variable 'x' because c++ prioritizes local variables when the name is…
-
1
votes1
answer800
viewsA: edges of an N x N matrix
// Inserindo NxN pecas aleatorias no tabuleiro for(int i= 0; i <= N; i++) { for(int j= 0; j <= N; j++) { // Se for a primeira linha OU coluna OU a ultima linha OU coluna // adiciona -1 if (i…
-
0
votes1
answer79
viewsA: Error when comparing matrices
The answer is shown several times because it is inside the loop, you should switch to store the result in a flag and ask outside the loop (second group of loops), like this: // Continua no laço…
-
0
votes6
answers6243
viewsA: check repeated number inside the array c#
You’re making two mistakes in your code: The first is that the loop is checking the number itself, ie when i and j are equal it compares the same number. The second error is the break, when finding…
-
0
votes2
answers679
viewsA: Strings and Arrays, problems getting the right result
You didn’t specify your problem! I was going to comment but as I do not have permission required, there are some errors in your code: // Aqui são dois sinais de iguais para comparar as respostas.…
-
6
votes5
answers391
viewsA: Concatenation in C
Use the sprintf function, char str[50]; char vetor[2][15] = {"192.168.2.200", "192.168.2.201"}; for(int i = 0; i < 2; i++) { sprintf(str, "shutdown -m %s -s -f", vetor[i]); system(str); } To…