#include <stdio.h>
#include <string.h>
struct Student
{
int num;
char name[32];
int sex;
int agt;
double score;
char addr[32];
};
int main()
{
int a;
struct Student stu1;
struct Student stu2;
a=10;
stu1.num = 1;//点运算符来访问结构体中的成员变量(域)。
stu1.agt = 10;
stu1.score = 98.6;
strcpy(stu1.name,"chenglicheng");
strcpy(stu1.addr,"福州");
printf("学号:%d, 年龄:%d, 成绩:%.2f, 名字:%s, 地址:%s\n",
stu1.num, stu1.agt, stu1.score, stu1.name, stu1.addr);
return 0;
}
C语言,结构体和数组的结合
最新推荐文章于 2023-08-15 15:39:57 发布