69,368
社区成员
发帖
与我相关
我的任务
分享
struct Person
{
char name[20];
int age;
};
struct Student
{
int num;
struct Person pers;
};
struct Student stud;
stud.num = 101;
memcpy(stud.pers.name, "seal", sizeof("seal"));
stud.pers.age = 20;
char str2[100] = { 0 };
memcpy(str2, &stud, sizeof(stud));
struct Student stud2 = *((struct Student*)str2);
cout << stud2.num << endl;
cout << stud2.pers.age << endl;
cout << stud2.pers.name << endl;