Posts by Júlio Evêncio • 482 points
28 posts
-
2
votes1
answer44
viewsA: How do I return a string from a char function? The returned value is NULL
One string in C is a character array, an array, ending with \0. When will we manipulate a string, we use your memory address, then to return a string we need to return the memory address of the…
-
1
votes3
answers119
viewsA: How do you not display repeated JAVA values
Apparently your solution only prints the repeating numbers to print the numbers that are not repeated in the vetor, you will need to go through your vetor, then check if a specific position repeats…
javaanswered Júlio Evêncio 482 -
1
votes3
answers67
viewsA: How to make the user choose the amount of elements in an ARRAY?
If the size of the vector cannot be determined in the compilation or at least guaranteed that it will not be too large then it should be used ponteiro and dynamically allocate memory. Example: int…
canswered Júlio Evêncio 482 -
3
votes1
answer111
viewsA: Sum with vector and pointer in C
The mistake is that you are using a ponteiro as if you a variável. The ponteiro stores an address. When you do this: soma = soma + vetor[i]; You’re putting a valor instead of a endereço. If you want…
-
1
votes1
answer71
viewsA: How to Insert a String into a Stack with C Language
Your code that you say works doesn’t work, on your machine it may seem to work, but it doesn’t do what you really want (the code generates several warning and that means your program will run…
-
7
votes1
answer102
viewsQ: What is the difference between a global variable and a global variable Static?
What is the difference between a global variable and a static global variable? Example: #include <stdio.h> int numero = 5; static int static_numero = 5; int main(void) { printf("numero: %d…
-
0
votes2
answers59
viewsA: error: expected Expression before struct
The Error Look at that part: int tam[ListaSimples->tamanho]; What is the value of ListaSimples->tamanho? Apparently this is your mistake. ListaSimples->tamanho is not a value because…
-
1
votes1
answer29
viewsA: Problems with assigning values from one vector to another, using malloc
Program error The error of your program is in this part: //inserindo os valores pares e impares em seus vetores for (i = 0; i < qtdPares; i++) { if (vetorPrincipal[i] % 2 == 0) { pares[i] =…
-
1
votes1
answer152
viewsA: How to write read information from a . csv file to a C Language struct
Program error The error of your program is to process the data within the struct as if they were string without leaving room for the character \0. Remember that in the linguagem C one string is a…
-
2
votes2
answers82
viewsA: Doubt with recursive function in C
Program error The error of your function is in the position of the return, in that passage: while (a > 0 && a >= b){ a = a - b; i++; return i; } The command return has two features:…
-
1
votes1
answer52
viewsA: error out of Bounds in doctor memory
Notice this excerpt in your code: Pessoa *p; Here we have a pointer, okay. Now let’s go to the realloc(): p = (Pessoa *) realloc(p,sizeof(Pessoa*)*linhas); The function realloc() will get the…
-
3
votes1
answer64
viewsA: Problems with the realloc() function in C language
Your program’s error is in using the realloc(), in that passage: // Esse trecho eh da funcao add table = (char *) realloc(table, (strlen(text) + 1) * sizeof(char)); Observe: void *realloc(void *ptr,…
-
0
votes1
answer27
viewsA: How can I re-load a C program if I have set a wrong value or want to run the program several times
Reload from a single reading Just leave the part of the code you want to do "Reload" inside a repeat command, that is, a loop. Example: do { printf("Valor de x0 = "); scanf("%f", &x0);…
canswered Júlio Evêncio 482 -
0
votes1
answer51
viewsA: "exited, floating point Exception" error in C
There are three logical errors in your program. Compare char as String if(strcmp(sexo, "f")==0){ sexoFem+=1; mediaAltMulheres+=altura[i]; } else if(strcmp(sexo, "m")==0){ sexoMasc+=1; } In this…
canswered Júlio Evêncio 482 -
0
votes1
answer77
viewsA: Dynamic stack - Compare values
First check if they have equal sizes, if not you already know they are different. If they are equal then you need to pop the elements of the two stacks and compare the values. Example: bool igual =…
c++answered Júlio Evêncio 482 -
1
votes1
answer43
viewsA: Printing the records of a file
Good night. reg.matricula keeping the license plate and the name together reg.matricula not holding the license plate and the name together. reg.matricula is being treated as a string, so far so…
canswered Júlio Evêncio 482 -
0
votes1
answer38
viewsA: What is wrong with my program for not giving the output of the structure object?
Good night! There are basically two errors in your code. The first is the time to pass the structure as argument in the function. Note: // Sua função pede um endereço de uma struct void…
-
0
votes1
answer48
viewsA: I’m having a problem running a repeat on C
Good afternoon. The repeat is only performed once because of the break within the if. I removed it here and it worked perfectly. Since you are working by passing by reference then you do not need to…
-
-1
votes2
answers135
viewsA: Passing a struct as parameter
Good night. Your code has two errors, the first one is about the scope (where it is visible) of your struct statement. Remember that a struct is a data type equal to int or char, but it is a data…
-
1
votes2
answers73
viewsA: Dynamic lease in C++
You can do this by creating a custom function to read string and read dynamically: char *ler_string(char *nome) { int i = 0; char letra; nome = malloc(sizeof(char)); do { letra = getchar(); if(letra…
-
0
votes1
answer37
viewsA: Filter string array in C and count how many repeat
All its data is loose, that is, one vector has no relation to the other and this makes the program difficult to read and change. An alternative is to use structs to relate the data to each other.…
-
2
votes2
answers78
viewsA: Help in solving the program
Good evening, your code there are some errors, so the text will be a little long... Prototypes of the functions Start with the prototypes of its functions: int menu (); void ler (FILE*); int gravar…
canswered Júlio Evêncio 482 -
0
votes1
answer28
viewsA: Can I centralize all my project Header’s into one? C/C++ Language
You can do all includes in your central header file, so when main. c call it, the file calls the other header files. Example: #ifndef CENTRAL_H_INCLUIDA #define CENTRAL_H_INCLUIDA #include "teste.h"…
-
0
votes1
answer136
viewsA: Return minimum and maximum values of a vector
Your code has two errors. Note that when you call your function you pass 3 addresses as arguments, so far so good, but the subtle detail is that you are passing the address of the vector: minimax…
-
0
votes1
answer45
viewsQ: Error declaring Java constants
I have just started my studies in Java and I have a problem declaring a constant: class Ex007 { public static void main(String[] args) { float comprimento, raio = 9f; public static final float PI =…
-
1
votes1
answer60
viewsA: Difficulties with Arrays
The problem with your code is in the if part. Note that when the function starts the value of j is 0, then ALWAYS the comparison of if will be: if(id == clientes[0]) Then the id value will only be…
-
1
votes1
answer32
viewsA: String for Vector(Array) in C
A string/word is nothing less than a vector of characters, that is, its string is already an array. You can use it with such a: char minha_string = "123+"; minha_string[0] = '2'; // Alterando o…
-
5
votes3
answers211
viewsA: Problem where IF and ELIF do not work in Python
The problem with your program is in the second if condition. I will divide this if into 2 for you to notice: Original: if x.lower() == "verão" or "verao": Divided: if x.lower() == "verão": if…