Search code examples
cstructvar

Struct variable


When we have :

struct node {
    char...
    int....
    struct node *....
}

typedef struct node Node;

and then we have a function like this:

int function(Node f){...}

What is this f ?


Solution

  • In the statement typedef struct node Node; you are giving alias name of struct node as Node by using typedef.

    So in the definition of function()

    int function(Node f){...}

    f is nothing but variable of struct node type.

    Also you can see the typedef declaration and meanings here http://en.cppreference.com/w/c/language/typedef