-1

given variable that define as char** const var; , what is defined here as const (var or *var) ?

And in the general case, how can I know it? (namely, given it: char**** const var , what is defined here as const?)

Micha Wiedenmann
  • 19,979
  • 21
  • 92
  • 137
AskMath
  • 415
  • 1
  • 4
  • 11
  • 1
    `var` is a constant pointer to a pointer to a `char`. It's the first-level pointer that is constant. Once you assign to `var` you can no longer reassign it. The amount of "stars" doesn't matter, it's the order of the `const` qualifier that is important. – Some programmer dude Jun 05 '18 at 07:46
  • Not sure about the duplicate, although the answer might be the same, OP seems more interested in the amount of `****`s. – Stefan Jun 05 '18 at 07:49
  • 1
    [This answer](https://stackoverflow.com/a/890595/4402721) to the linked duplicate gives the rule for what is const. – drRobertz Jun 05 '18 at 07:52

1 Answers1

0

You read right-to-left. The const refers to what is to the left. The exception is that a declaration may start with const, in which case it refers to the thing on the right.

char const * const is a constant pointer to a constant char. So char ** const is a constant pointer to a pointer-to-char.

ravnsgaard
  • 922
  • 1
  • 10
  • 20