为什么这个c++程序运行到后面运行终止

程序程序源码如下:

#include "stdafx.h"
#include

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
char firstname[20];
char lastname[20];
char grade;
int age;

cout << "what is your first name? ";
cin.getline(firstname,20);
cout << "what is your last name? ";
cin.getline(lastname,20);
cout << "what letter grade do you deserve? ";
cin >> grade;
cout << "what is your age? ";
cin >> age;

cout << "Name:" << lastname << "," << firstname << endl;
cout << "Grade:" << grade << endl;
cout << "Age:" << age << endl;
return 0;

}

在运行到cin>>age;时,我输入年龄后就直接被终止程序了是为什么,为什么后面的代码运行不了了??求指教

查看全部
baidu_24736703
Kobe___Bryant
2016/04/21 07:48
  • c++
  • 源码
  • ios
  • 点赞
  • 收藏
  • 回答
    私信

5个回复