1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| #include<stdio.h> #include<string.h> struct stu{ int num; char name[32]; int age; }; int main(int argc,char *argv[]){ struct stu lucy={1234,"小辰",18}; struct stu bob; #if 0 bob.num=lucy.num; strcpy(bob.name,lucy.name); bob.age=lucy.age; printf("%d %s %d\n",bob.num,bob.name,bob.age); #endif
#if 0 bob=lucy; printf("%d %s %d\n",bob.num,bob.name,bob.age); #endif memcpy(&bob,&lucy,sizeof(struct stu)); printf("%d %s %d\n",bob.num,bob.name,bob.age); return 0; }
|