0

I am following a C tutorial for a Linked List and I am building the node. However, I do not understand why the * operator comes at the end of the node variable versus in front of it. I thought pointers came in front of the word. So which is the pointer? "next" or "node"?

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

Thank you.

Colorful Codes
  • 577
  • 4
  • 16

1 Answers1

1

struct node is the type so it comes in front of that, like int* num, only in this case type int is only one word.

Another hint to this is that variable names can only have one word.

So struct node* (pointer to struct node) is the type, and next is the name of the variable.

See here

anastaciu
  • 23,467
  • 7
  • 28
  • 53