Variables

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.


Syntax
typedef oldTypeName newTypeName;

Notes

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


Example
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
Documentation

GNU C Manual - Typedef

Add to Slack

< Structures   |   If Statement >

© 2019 SyntaxDB. All Rights Reserved.