Search code examples
c++structlinked-liststructure

Why to use the struct keyword along with structure name in linked list to create pointer of node


struct linklist
{
    int data;
    struct linklist *next;
}

Why using struct linklist in front of *next? One can create a pointer simply by *node?


Solution

  • Why we are using struct linklist in front of '*next'

    You don't need to use an elaborated type specifier here. So I suppose that you use it because you can.

    Or perhaps you intend to use the struct across language boundaries, in which case you use it because it is necessary to use it in C.