VERY strange problem using the function gets()
> I hope someone can help me.
> Simply: if I type these lines...
> cout << "Sentence1";
> cout << "Sentence2";
> I get the result:
> <prompt for the input of the string>
> Does someone know why MS Visual C++ executes the gets()
> function before the first cout instruction?
Because you didn't flush the output stream. I believe cout will flush
automatically when you cout << endl, but you didn't. You need an explicit
Also, DO NOT use gets. It doesn't allow you to specify the size of the
buffer you hand it, so there's no way to prevent potential buffer overflows.
Since you're using cout, try to use cin instead.