菜鸟求教,谢谢!
struct Date{int month;
int day;
int year;
};
struct Person{
char name[20];
char sex;
struct Date birthday;
unsigned long num; /*身份证号码*/
};
#include <stdio.h>
int main(void)
{
struct Person p1={"wanglin",'M',12,15,1974,111000222};
struct Person p2;
p2.name[6]="wenya"; /*这里如果我需要单独赋值,应该怎样呢?我这里是错误的*/
p2.sex='W';
p2.num=111000223;
p2.birthday=p1.birthday;
printf("Person1: %s, %c, %d-%d-%d, %lu\n",p1.name,p1.sex,p1.birthday.month,p1.birthday.day,p1.birthday.year,p1.num);
printf("Person2: %s, %c, %d-%d-%d ,%lu\n",p2.name,p2.sex,p2.birthday.month,p2.birthday.day,p2.birthday.year,p2.num);
return 0;
}
问题在注释里,谢谢了~