#include
typedef struct stu
{
int id;
char name[15];
int age;
char sex;
}stu;
void dis_stud(stu *s)
{
printf("%ld\n",sizeof(s));
printf("%d %s %d %c\n",s->id, s->name, s->age, s->sex);
s->age = 26;
}
int main()
{
stu s1 ={1, "tom", 32, 'm'};
stu s2 ={2, "moe", 12, 'w'};
dis_stud(&s1);
dis_stud(&s1);
return 0;
}
结构体 套用
#include
#include
struct data
{
int year;
int month;
int day;
};
typedef struct stu
{
int id;
char name[15];
int age;
char sex;
struct data birth;
}stu;
void dis_stud(stu *s)
{
printf("%d %s %d %c\n",s->id, s->name, s->age, s->sex);
printf("%4d-%2d-%2d\n",s->birth.year, s->birth.month, s->birth.day);
}
int main()
{
stu s ={1, "tom",19,'w',{2000,9,21}};
dis_stud(&s);
return 0;
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)