Ok, well, some things are unclear to me about how cin works.
If we for example do this:
And if the input looks likeCode:#include <cstdlib> #include <iostream> using namespace std; int main() { int answer = 0; string s; cin >> answer; cin >> s; cout << s << endl; system("PAUSE"); return EXIT_SUCCESS; }
not_integer
Why wont cin >> s pick it up?
if the first cin >> answer fails, it pushes the first readed character back to input. so the next cin should pick it up.
but this isnt the case. why?
edit: i also came accros information that cin's bad and easily error prone. Should i avoid using it?
I want my programs to be safe ofcourse.
I come from a C background, thats why this is strange to me.