#include <stdio.h> struct student{ int ID; char name[48]; int age; }; int main(){ //赋值: struct student s1 = { 1, "lifei", 24 }; struct student s2 = { .ID = 2,.name="letben",.age = 28}; struct student s3 = { 0, "qingwa", .ID = 3, .age = 25 }; //使用: 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 0; }
时间: 2024-10-12 20:17:12