typedef struct person{
char name[32];
char sex;
char age;
char num[16];
char addr[128];
} people_t, *people_p, **people_pp;
int main()
{
people_t x;
char tmp[20] = "zhangsan";
people_p c = &x;
*(c->name) = "zhangsan";
int z = strcmp(tmp, c->name);
printf("%s\n%d\n", c->name, z);
system("pause");
return 0;
}
1.代碼是這樣,為什麼兩個都是“zhangsan”,但是用strcmp比較出來的值為-1,明顯與預期結果不符,
不知道哪出錯了?
2.還有*(c->name) = "zhangsan";這行代碼對嗎?如果不能這樣寫,那要怎麼寫?
**
*(c->name) = "zhangsan";
**
改為
strcpy(c->name,"zhangsan");
指針聲明和數組聲明(例如 char *a 和 char a[] )具體都有哪些區別