Placement of the asterisk in pointer declarations

前端 未结 13 884
闹比i
闹比i 2020-11-22 04:36

I\'ve recently decided that I just have to finally learn C/C++, and there is one thing I do not really understand about pointers or more precisely, their definition.

13条回答
  •  广开言路
    2020-11-22 05:36

    The rationale in C is that you declare the variables the way you use them. For example

    char *a[100];
    

    says that *a[42] will be a char. And a[42] a char pointer. And thus a is an array of char pointers.

    This because the original compiler writers wanted to use the same parser for expressions and declarations. (Not a very sensible reason for a langage design choice)

提交回复
热议问题