Typedef in C


In C programming, "typedef" is a keyword that allows you to create an alias or synonym for an existing data type. This can make the code more readable and maintainable by giving a more meaningful name to a complex or obscure data type.
   Syntax :
        typedef data_type new_name ;

For example, you can use typedef to create an alias for the "int" data type, like this:
   Example :
        typedef int INTEGER ;

With this definition, you can use "INTEGER" in place of "int" throughout your code.

Source Code

//typedef in C Programming
#include<stdio.h>
 
typedef struct student
{
    char *name;
    int age;
    float per;
} student;
 
int main()
{
    typedef int INTEGER;
    INTEGER a;
    student o;
 
    a=100;
    printf("\nA : %d",a);
 
 
    o.name="Tutor Joes";
    o.age=30;
    o.per=85.5;
 
    printf("\nName        : %s",o.name);
    printf("\nAge         : %d",o.age);
    printf("\nPercent     : %f",o.per);
    return 0;
}
 
 
To download raw file Click Here

Output

A : 100
Name        : Tutor Joes
Age         : 30
Percent     : 85.500000

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C