Why doesn't std::getline block?
I have this code in an Objective-C class (in an Objective-C++ file): +(NSString *)readString { string res; std::getline(cin, res); return [NSString stringWithCString:res.c_str() encoding:NSASCIIStringEncoding]; } When I run it, I get a zero-length string, Every time. Never given the chance to type at the command line. Nothing. When I copy this code verbatim into main() , it works. I have ARC on under Build Settings. I have no clue what it going on. OSX 10.7.4, Xcode 4.3.2. It is a console application. It means there is input waiting to be read on the input. You can empty the input: cin.ignore