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

后端 未结 8 1240
终归单人心
终归单人心 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 21:00

    I prefer the following style:

    Type *pointer;
    

    Why? Because it is consistent with the mindset the creators of the language tried to establish:

    "The syntax of the declaration for a variable mimics the syntax of expressions in which the variable might appear."

    (The C Programming Language by Brian W. Kernighan & Dennis M. Ritchie, ansi c version, page 94)

    It's easy to write FORTRAN in any language, but You always should write [programming language X] in [programming language X].

提交回复
热议问题