USE of "TYPEDEF" in C-language.
typedef is used to assign user defined name to data types in c. for example if i am too lazy programmer and my team leader assign me a task of developing a program that consist of many variable with long unsigned data type. so in that case i can take help of typedef function available in C.
So i might defined unsigned long as ulong or ul in following way :
The proper format to use is as follow:
typedef Previous_name New_name ;
To demonstrate use of typedef function, i have prepared one program having two variable defined by inbuild data type and user defined data type. you will find size of both variable is same.
#include<stdio.h>
#include<conio.h>
void main()
{
typedef unsigned long ulong;
unsigned long a = 0;
ulong b = 0;
printf("The size to store a inside memory is %d bytes \n ", sizeof(a) );
printf("The size to store b inside memory is %d bytes \n", sizeof(b));
}
No comments:
Post a Comment