Type definitions and structures
Type definitions make it possible to create your own variable types. In the following example we will create a type definition called “intpointer” (a pointer to an integer):
#include<stdio.h>
typedef int *int_ptr;
int main()
{
int_ptr myvar;
return 0;
}
It is also possible to use type definitions with structures. The name of the type definition of a structure is usually in uppercase letters. Take a look at the example:
#include<stdio.h>
typedef struct telephone
{
char *name;
int number;
}TELEPHONE;
int main()
{
TELEPHONE index;
index.name = "Jane Doe";
index.number = 12345;
printf("Name: %s\n", index.name);
printf("Telephone number: %d\n", index.number);
return 0;
}