Difference between const char*, char const*, const char const* & string storage

后端 未结 6 1801
后悔当初
后悔当初 2020-12-24 15:50

First of all, what\'s the difference between:

(1) const char*
(2) char const*
(3) const char const*

I\'m fairly certain I understand this f

6条回答
  •  自闭症患者
    2020-12-24 16:12

    1. const char* means pointer to constant character
    2. char const* means exactly the same as 1. (you probably were going for char* const, which is constant pointer to a character.)
    3. const char const* is invalid as Johannes already pointed out

    String literals are usually stored in a read-only data segment of your executable, but this is by no means guaranteed.

提交回复
热议问题