I'm trying to learn C++. Sometimes I get confused by C style strings and its functions. I've been using
char var[1];
fflush(stdin);
gets(var);
to write a string into a char array. I don't know if thats the most efficient way but thats how I've been taught.
Now, I'm making a console program in which I read some variables that way and make things with them. It's all working fine but I have a char array, estudios[1] and I have to compare it with strcmp (I'm not talking about the strcmp(estudios, "N") != 0 I wrote below) to a specific value and i found that te result of the comparation was always the same no matter the value estudios had. I realized that after this chunk of code:
if (strcmp(estudios, "N") != 0){
cout << "Estudios completos o incompletos?" << endl;
fflush(stdin);
gets(indicador);
}
Let's say that the value of estudios is "P". Before the code i showed the value of estudios is "P" but after it it changes it value to "". To be more precise it changes after the gets(indicator); Why does that happen? Is it supposed to do that? Sorry for such a newbie question