const and pointers in C

后端 未结 5 1981
星月不相逢
星月不相逢 2021-02-18 17:47

The use of const with a pointer can make the pointee not modifiable by dereferencing it using the pointer in question. But why neither can I modify what the pointer is not direc

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-18 18:29

    Since a pointer can also be used as an array (think about argv), the compiler restricts each access in which the pointer is involved. This way the whole array is read-only.

提交回复
热议问题