开发者

using getline for a c++ string to include spaces [duplicate]

This question already has answers here: Closed 11 years ago.

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜