-
Problems with getline()?
So, after finally figuring out how to read input with spaces, I end up with a second problem: I have to hit the enter key twice for the system to finally get the line.
PHP Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s;
getline(cin,s);
cout << s;
return 0;
}
That's my code. Whenever I enter something, I hit the enter key, and nothing happens. When I hit it a second time, it shows the output from the cout. Any ideas?
-
Let me guess, you're using Visual Studio 6? I believe it's a bug in that. Maybe a service pack will fix? Not sure.
-
Yup, buggy...
See
Knowledge Base Article #240015 for fix.
Smitty
p.s. try that link a few times or goto MS & search for 240015
the link is flaky for some reason.
-
lots of thanks, guys. This was driving me crazy.