const and pointers in C

后端 未结 5 1984
星月不相逢
星月不相逢 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:33

    ptr +2 simply has the same type as ptr namely is a pointer to a const object.

    Pointer arithmetic supposes that the object that is pointed to is an array of all the same base type. This type includes the const qualification.

提交回复
热议问题