1
I need the main string "vector" to be traversed to the delimiter '=' and copy the values before '=' to "second" and the values after '=' to "third". I’m sure there’s a smarter way to do this, but as a beginner, I’m having a hard time thinking about the right code for this requirement.
int tam = 256;
char vetor[tam];
char segundo[tam];
char terceiro[tam];
int i = 0;
int j = 0;
fgets(vetor, tam, stdin);
for (i = 0; i < strlen(vetor); i++){
if (vetor[i] == '='){
segundo[i] = vetor[i];
} //continuar percorrendo a string e copiar valores após o delimitador '=' para o vetor "terceiro"
}
The intention is that when the expression is inserted for example: 9+8i*8-3i= it is possible to treat it in different vectors as follows: vector 1: 9 vector 2: +8i vector 3: *8 vector 4: -3i
If there are better ideas for calculating an expression with complex numbers, I am open to ideas =) Ps.1: I try to make the most of C’s native functions, trying to make the most of the external library functions.
Thanks for the answer! I did so and at the time of rotating, the vectors are divided properly as I expected even. The problem is that right after the results of the 2 resulting strings, some strange characters appear as "ýÿ " in the line just below the results. What could be?
– 01010000
Oh yes, instead of third[j] = ' 0'; It was supposed to have been third[j - i - 1] = ' 0'; I got the answer right.
– Sérgio Mucciaccia