What is the purpose of the first “node” in the declaration: “typedef struct node { - - - } Node;”?

前端 未结 6 1347
醉话见心
醉话见心 2020-12-30 08:06

I am studying code examples from my professor in order to become better acquainted with linked data structures.

In our linked-list.c example the professor defines a

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-30 09:00

    Take a look at this declaration:

    struct node {
      int data;
      struct node *next;
    };
    
    typedef struct node Node;
    

    This can be combined into a single statement (simplifying a declaration):

    typedef struct node {
      int data;
      struct node *next;
    } Node;
    

提交回复
热议问题