【问题标题】:What is the difference between the * operator at the end of struct name vs in front of struct name? [duplicate]结构名称末尾的 * 运算符与结构名称前面的 * 运算符有什么区别? [复制]
【发布时间】:2020-09-19 05:29:51
【问题描述】:

我正在关注链接列表的 C 教程,并且正在构建节点。但是,我不明白为什么 * 运算符出现在节点变量的末尾而不是它的前面。我认为指针出现在这个词的前面。那么哪个是指针? “下一个”还是“节点”?

struct node {
    int value;
    // next pointer, should point to the next node in the list
    struct node* next; // pointer of structure type
};

谢谢。

【问题讨论】:

    标签: c pointers


    【解决方案1】:

    struct node 是类型,所以它出现在它的前面,比如int* num,只有在这种情况下,int 类型只有一个词。

    另一个提示是变量名只能有一个单词。

    所以struct node*(指向结构节点的指针)是类型,next 是变量的名称。

    See here

    【讨论】:

      猜你喜欢
      • 2017-08-01
      • 2013-08-06
      • 2011-12-08
      • 2011-03-05
      • 2013-02-17
      • 1970-01-01
      • 1970-01-01
      • 2013-06-16
      • 1970-01-01
      相关资源
      最近更新 更多