【发布时间】:2012-01-10 01:19:02
【问题描述】:
#include <iostream>
#include <string>
using namespace std;
int main () {
string str;
int age;
cout << "Please enter age: ";
cin>>age;
cout << "Please enter full name: ";
getline (cin,str);
cout << "Thank you, " << str << ".\n";
}
为什么当我使用 uperator >> 输入整数时函数 getline() 不起作用? int 输入有什么更好的用途?
【问题讨论】:
-
定义“不工作”。发生了什么你不喜欢的事情?