B********s 发帖数: 3610 | 1 我定义一个string对象s,希望从键盘输入一个字符串,回车结束
cin >> s 输入的字符串不能有空格
getline(cin,s,'\n') 则需要按两下enter
请问有没有更好的办法? | I*l 发帖数: 1649 | 2 just getline (cin, s);
【在 B********s 的大作中提到】 : 我定义一个string对象s,希望从键盘输入一个字符串,回车结束 : cin >> s 输入的字符串不能有空格 : getline(cin,s,'\n') 则需要按两下enter : 请问有没有更好的办法?
| b******u 发帖数: 10 | 3 Quoted from http://support.microsoft.com/kb/240015
Modify the getline member function, which can be found in the following
system header file string, as follows:
else if (_Tr::eq((_E)_C, _D))
{_Chg = true;
// _I.rdbuf()->snextc(); /* Remove this line and add the line
below.*/
_I.rdbuf()->sbumpc();
break; }
【在 B********s 的大作中提到】 : 我定义一个string对象s,希望从键盘输入一个字符串,回车结束 : cin >> s 输入的字符串不能有空格 : getline(cin,s,'\n') 则需要按两下enter : 请问有没有更好的办法?
| b******u 发帖数: 10 | 4 I assume LZ built the code on Win32. The original code works fine on FreeBSD.
line
【在 b******u 的大作中提到】 : Quoted from http://support.microsoft.com/kb/240015 : Modify the getline member function, which can be found in the following : system header file string, as follows: : else if (_Tr::eq((_E)_C, _D)) : {_Chg = true; : // _I.rdbuf()->snextc(); /* Remove this line and add the line : below.*/ : _I.rdbuf()->sbumpc(); : break; } :
| B********s 发帖数: 3610 | 5 对,我是在win32下做的
FreeBSD.
【在 b******u 的大作中提到】 : I assume LZ built the code on Win32. The original code works fine on FreeBSD. : : line
|
|