C语言结构体的引入

时间:2020-12-25 21:38:21
#include <stdio.h>

struct student{
int ID;
char name[];
int age;
}; int main(){
//赋值:
struct student s1 = { , "lifei", };
struct student s2 = { .ID = ,.name="letben",.age = };
struct student s3 = { , "qingwa", .ID = , .age = }; //使用:
printf("%s\n", s1.name);
printf("%d\n", s1.ID);
printf("%d\n", s1.age);
printf("二号同学的信息:id:%d,姓名:%s,年龄:%d\n", s2.ID, s2.name, s2.age);
printf("三号同学的信息:id:%d,姓名:%s,年龄:%d\n", s3.ID, s3.name, s3.age); getchar(); return ; }