C Tutorial TypeDef

Data types in C
Arrays in C
Pointers in C
Pointer Dereferencing
The & Operator
Uninitialized Pointers
Using Pointers
C Strings
String Code Example
Large Strings
Char type pointers




A typedef statement introduces a shorthand name for a type. The syntax is...


typedef <type> <name>;



The following defines Fraction type to be the type (struct fraction). C is case sensitive, so fraction is different from Fraction. It's convenient to use typedef to create types with upper case names and use the lower-case version of the same word as a variable.


typedef struct fraction Fraction;


Fraction fraction;   // Declare the variable "fraction" of type "Fraction"

//  which is really just a synonym for "struct fraction".



The following typedef defines the name Tree as a standard pointer to a binary tree node where each node contains some data and "smaller" and "larger" subtree pointers.


typedef struct treenode* Tree;

struct treenode {

int data;

Tree smaller, larger;   // equivalently, this line could say

};                         // "struct treenode *smaller, *larger"

Want To Know more with

Video ???