Convention for pointer *

后端 未结 1 992
礼貌的吻别
礼貌的吻别 2020-12-19 12:10

Out of curiosity; why is convention for pointers in C languages like this:

NSString *str = ...

Wouldn\'t be more appropriate to write:

相关标签:
1条回答
  • 2020-12-19 12:55

    If you declare multiple pointer variables in a single declaration, you must write

    char *a, *b;
    

    since the declaration

    char* a, b;
    

    would declare a as a char pointer, but b as a plain char. IOW, this spacing shows that the asterisk really binds to the name only where it appears.

    0 讨论(0)
提交回复
热议问题