hi, i have a little question about cin.getline and cin.get...
Code:char seleccion(){ char opcion[5]; while(true){ menu1(); cin.getline(opcion,5); cin.clear(); if(strcmp(opcion,"new") == 0) return 1; else if(strcmp(opcion,"show")==0) return 2; else if(strcmp(opcion,"mod")==0) return 3; else if(strcmp(opcion,"del")==0) return 4; else if(strcmp(opcion,"exit")==0) return 5; } }
the problem is that after the first time the getline function doesn't allow me to enter anything, it just fills the string with a newline
like if i do this
what i get isCode:char something[5]; cin.getline(something,5); cout << something << endl; cin.getline(something,5); cout << something << endl; cin.getline(something,5); cout << something << endl;
can please anyone tell me why this happen and what can i do to solve it?Code:whatever_i_wrote newline newline
(sorry if it's hard to understand, english isn't my mother language)



LinkBack URL
About LinkBacks



CornedBee