定义一个结构体变量stu,成员包括学号,姓名,性别,成绩,定义一个指针变量p指向该结构体变量stu

2025-04-15 01:53:14
推荐回答(1个)
回答1:

#include
#include
using namespace std;
int main( )
{
struct Student
{
int num;
string name;
char sex;
float score;
};
Student stu;
Student *p=&stu;
stu.num=10001;
stu.name="KYO";
stu.sex='F';
stu.score=89.5;
cout<

num<<" "<<(*p).name<<" "<<(*p).sex<<" "<<(*p).score< return 0;
}