using getline for a c++ string to include spaces [duplicate]
Possible Duplicate:
Reading a full line of input
I came across this snippet of code as a way to input a string (not a c st开发者_JS百科ring of char type) and have it read the whole line rather than stopping at the first space. Can someone give me an actual example of this where I want to input the line until a newline character is hit?
istream& getline(istream& ins, string& strVar);
Simple google search of "getline sample": http://msdn.microsoft.com/en-us/library/3ah895zy(v=vs.80).aspx
string s;
getline(cin, s);
精彩评论