struct Student{
int num;
char name[20];
char sex;
};
int main()
{
Student student1 = {10001,"zhang xin",'M'};
cout<<&student1.num<<endl;
cout<<&student1.name<<endl;
cout<<&student1.sex<<endl;
return 0;
}
定义上面的结构体,但是输出cout<<&student1.sex<<endl; 结果却是乱码,理论上不应该是name的地址加上20?已考虑到字节对齐情况!