“Address of” (&) an array / address of being ignored be gcc?

后端 未结 5 1043
盖世英雄少女心
盖世英雄少女心 2020-12-05 19:00

I am a teaching assistant of a introductory programming course, and some students made this type of error:

char name[20];
scanf(\"%s\",&name);

5条回答
  •  死守一世寂寞
    2020-12-05 20:00

    Actually, they are different, they don't have the same type at least.

    But in C, the address of the array is the same as the address of the first element in the array that's why "they are not different", basically, they point to the same thing.

提交回复
热议问题