Skip to main content

Command Palette

Search for a command to run...

typedef in C

Updated
1 min readView as Markdown

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);