typedef in C

·

1 min read

To give a new name to a type

A normal convention of declaring a struct:

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

struct Node* newNode = NULL;
void AddToEnd(struct Node **ppList, int value);
int Count(struct Node *list);

with typedef (Notice that you do not need to put type struct):

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

Node* newNode = NULL;
void AddToEnd(Node **ppList, int value);
int Count(Node *list);