Placement of the asterisk in pointer declarations

前端 未结 13 881
闹比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:32

    White space around asterisks have no significance. All three mean the same thing:

    int* test;
    int *test;
    int * test;
    

    The "int *var1, var2" is an evil syntax that is just meant to confuse people and should be avoided. It expands to:

    int *var1;
    int var2;
    

提交回复
热议问题