怎样赋值struct中的char[20]数组??我想其中一定有原因,就是看了半天看不出来
前辈帮忙看看吧!
void test_struct(){
struct person{
int no;
char name[20];
char *add;
int age;
};
struct person John;
John.no=1;
John.name="John";//用vc6编译出出错
//error C2106: '=' : left operand must be l-value
//}
在初始化时可以赋值,或者用scanf("%s",John.name);也可以赋值成功
有谁可以说一下为何
Jhon.name="John";
为何不行吗?我想其中一定有原因,就是看了半天看不出来