Use typedef to create new type name - C Data Type

C examples for Data Type:typedef

Introduction

You can create an alias for a type using the typedef keyword followed by the type and alias name.

typedef unsigned char BYTE;

The alias can be used as a synonym for its specified type.

BYTE b; /* unsigned char */

The following code uses typedef on a struct.

Demo Code


#include <stdio.h>

typedef struct { int points; } score;
int main()//  w  w w .  j  a v  a2  s .  com
{
    score a, b, c;
    a.points = 10;

    printf("%d",a.points);

    return 0;
}

Result


Related Tutorials