In C, what is the correct syntax for declaring pointers?

后端 未结 8 1265
终归单人心
终归单人心 2020-11-27 20:32

I vaguely recall seeing this before in an answer to another question, but searching has failed to yield the answer.

I can\'t recall what is the proper way t

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 20:46

    Those two are exactly the same.

    However, for the purposes of declaring multiple variables, as in below:

    int * p1, p2;
    

    where p1 is of type pointer to int, but p2 is of type int. If you wished to declare p2 as a pointer to int, you have to write:

    int *p1, *p2;
    

提交回复
热议问题