What is the difference between char * const and const char *?

前端 未结 19 1150
执笔经年
执笔经年 2020-11-22 03:31

What\'s the difference between:

char * const 

and

const char *
19条回答
  •  心在旅途
    2020-11-22 03:46

    The const modifier is applied to the term immediately to its left. The only exception to this is when there is nothing to its left, then it applies to what is immediately on its right.

    These are all equivalent ways of saying "constant pointer to a constant char":

    • const char * const
    • const char const *
    • char const * const
    • char const const *

提交回复
热议问题