Type Definition in C

Typedef is used to create new names for types and structures. It can save the user from typing out longer, complex data types or structures.

typedef oldTypeName newTypeName;


A typedef is typically used to give a structure a name, instead of having to type out 'struct structName' every time.

typedef unsigned int u_int; //giving 'unsigned int' a name of u_int

//Now, doing this
u_int myNumber;
//Is the same as doing this (except with a different variable name of course)
unsigned int myNumber2;

See Also

GNU C Manual - Typedef

Add to Slack

< Structures   |   If Statement >

© 2019 SyntaxDB. All Rights Reserved.