在下面的代码,我的函数getline完全跳过,不会提示输入。
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <istream>
using namespace std;
int main()
{
int UserTicket[8];
int WinningNums[8];
char options;
string userName;
cout << "LITTLETON CITY LOTTO MODEL: " << endl;
cout << "---------------------------" << endl;
cout << "1) Play Lotto " << endl;
cout << "q) Quit Program " << endl;
cout << "Please make a selection: " << endl;
cin >> options;
switch (options)
{
case 'q':
return 0;
break;
case '1':
{
cout << "Please enter your name please: " << endl;
getline(cin, userName);
cout << userName;
}
cin.get();
return 0;
}
}
它是如何不工作?在什么条件下?运行时错误?编译器错误?你想做什么?你能把它结晶到一个更小的例子吗? – 2011-05-10 16:55:58
不错的方式让人们开始思考... – 2011-05-10 16:56:27
也,这功课?如果是这样,它应该被贴上标签。 – 2011-05-10 16:56:40