大家好我刚刚开始学习c ++一小时前我遇到了这个错误:
#include "stdafx.h"
#include <iostream>
#include <string>
int main()
{
using namespace std;
string name;
int age;
cout << "How old are you ?";
cin >> age;
cout << "Awesome, what's your name?";
getline(cin, name);
cout << "Nice name, " << name << "!";
return 0;
}
getLine(cin,name)被完全忽略并直接转到下一个cout并以此结束:
http://puu.sh/9drtu/80449b62ac.png
感谢。