#include<iostream>
using namespace std;
const int size=20; // 为什么会size不明确?
struct Student
{
char firstname[size];
char lastname[size];
char grade;
int age;
};
void display(Student);
int main()
{
Student stu; //创建结构变量
cout << "What is your first name?";
cin.getline(stu.firstname, size);
cout << "What is your last name?";
cin.getline(stu.lastname, size);
cout << "What letter grade do you deserve?";
cin>>stu.grade;
cout << "What is your age?";
cin >>stu.age;
display(stu);
return 0;
}
void display(Student information)
{
cout << "Name:" << information.lastname << " , " << information.firstname << endl
<< "Grade:" << char(information.grade+1) << endl
<< "Age:" << information.age << endl;
}
onemoo
onemoo
onemoo
慕的地8582982