#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct stu {
char* name, gender;
int score;
};
void main()
{
struct stu a = { NULL,'m',290 }, b;
a.name = (char*)malloc(10);
strcpy(a.name, "Zhao");
b = a;
b.gender = 'f';
b.score = 350;
strcpy(b.name, "Qian");
printf("%s,%c,%d\n", a.name, a.gender, a.score);
printf("%s,%c,%d", b.name, b.gender, b.score);
}
为什么最后的结果是
Qian,m,290
Qian,f,350
而不是
Zhao,m,290
Qian,f,350