编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第4章编程练习1
#include <iostream>
//#include <string>
using namespace std;
struct stu
{
char fname[10];//这里若用string fname
char lname[10];//同样这里若用string lname
char grade;
int age;
};
int main()
{
stu stu1;
cout<<"What is first name? ";
cin.getline(stu1.fname,10);//getline(cin,stu1.fname)存在输入两次enter,才会运行到下一句cout<<"What...",??
out<<"What is your last name? ";
cin.getline(stu1.lname,10);
cout<<"What letter grade you deserve? ";
cin>>stu1.grade;
cout<<"What is your age? ";
cin>>stu1.age;
cout<<"Name: "<<stu1.fname<<", "<<stu1.lname<<endl;
cout<<"Grade: "<<(char) (stu1.grade+1)<<endl;
cout<<"Age: "<<stu1.age<<endl;
system("pause");
return 0;
}