#include<stdio.h>
#include<math.h>
#include<string.h>
struct Student
{
long num;
char name[50];
char sex;
float score;
};
int main() {
struct Student stu_1;
struct Student *p;
p = &stu_1;
stu_1.num = 10101;
strcpy_s(stu_1.name, "Liming");
stu_1.sex = 'M';
stu_1.score = 99.5;
printf("No.:%d\nName:%s\nSex:%c\nSecore:%f\n", stu_1.num, stu_1.name, stu_1.sex, stu_1.score);
printf("No.:%d\nName:%s\nSex:%c\nSecore:%f\n", (*p).num, (*p).name, (*p).sex, (*p).score);
}
通过指向结构体变量的指针访问结构体变量中的成员
最新推荐文章于 2023-03-01 17:04:16 发布