0
I’m trying to solve the following URI problem
the problem is time to make the EOF happen, I understand more or less how it works but still can not make my program "stop".
int main(){
string entrada;
Arv_bin * arv = new Arv_bin;
getline(cin, entrada);
do{
entrada = remove_espacos(entrada);
arv->raiz = cria_nodo(entrada, 0, entrada.length()-1);
imprime_arv(arv);
getline(cin, entrada);
if(cin.eof()) cout << endl;
}while(!cin.eof());
return 0;}
Is there something wrong with my condition? What should I do?
Note that if you give EOF at first reading you will treat it anyway. Change the
do { ...} while
by awhile(!cin.eof()) {...
. This is unnecessaryif(cin.eof()) cout << endl;
just putcout << endl;
after the loop.– anonimo