【发布时间】:2017-02-02 05:18:23
【问题描述】:
为什么当我为第一个问题输入大量信息时,我的代码会跳过最后一个问题?我做错了什么?
const int SIZEC =31;
char phrase[SIZEC];
cout << " Provide a phrase, up to 30 characters with spaces. > " << endl;
cin.getline(phrase, SIZEC);
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << " The phrase is: " << phrase << endl;
cout << endl;
cout << " Using sring Class Obects " << endl;
cout << "--------------------------" << endl;
cout << endl;
string leter;
cout << " Provide a single character > " << endl;
cin >> leter;
cout << " The single character is: " << leter << endl;
cout << endl;
如果需要此之前的代码,请告诉我,我会添加它。
【问题讨论】:
-
我的老师希望它是一个字符串.. :(
-
don't use
endl除非您知道并需要它的副作用 -
嗯。什么“副作用”?它对我来说效果很好......从来没有问题。
-
请在询问之前阅读链接