बिजनेस मार्केटिंग का लो कॉस्ट फंडा , अपने मोबाइल से ऑटो sms भेजकर मार्केटिंग करे विजिट करे http://autotextsms.com/ बिजनेस मार्केटिंग का लो कॉस्ट फंडा http://autotextsms.com/

Search This Blog

Translate

Type def in c program example

  Type def  in c ,what is  Type def  in c programming explain example with source code,where Type def  used,advantages of Type def ,example of Type def  with source code c programming 

typedef keyword used to create new data type name to given structure in c.
in following program we have declare stucture stud as using keyword struct stud followed by definition of that structure .

when you want to create a veritable of struct stud type you have to use following line 
struct stud s1;
i.e. you have created variable s1 having type struct stud;

every time whenever you want to declare a variable of structure you have to use struct stud
by using typedef keyword you can define your own name and by using that name you can declare a variable as shown in following program .
i have defined mca as data type  using typedef  as
 typedef struct stud mca;
as after using this line i have declare new variable s1 using  mca as followes
 mca s1; 



#include

#include
struct stud{ int rno;
    char nm[20];
    };
void pr(struct stud *); //fn declaration
void main()
{
 //struct stud s1;
 typedef struct stud mca;
 mca s1;
  clrscr();
  printf("enter structure element : \n ");
  scanf("%d",&s1.rno);
  fflush(stdin);
  gets(s1.nm);
  pr(&s1);
  getch();

}
void pr(struct stud *s)
{
 printf("\n_____________________\n");
 printf("id=%d  Name=%s",s->rno,s->nm);

}

C Program example List