self referential struct definition?

后端 未结 9 1743
死守一世寂寞
死守一世寂寞 2020-11-22 11:09

I haven\'t been writing C for very long, and so I\'m not sure about how I should go about doing these sorts of recursive things... I would like each cell to contain another

9条回答
  •  星月不相逢
    2020-11-22 12:11

    A Structure which contain a reference to itself. A common occurrence of this in a structure which describes a node for a link list. Each node needs a reference to the next node in the chain.

    struct node
    {
           int data;
           struct node *next; // <-self reference
    };
    

提交回复
热议问题