structure without tags in C ?


The structure tags name is optional. The structure definition without tag name is called struct without tags.


Syntax:-
struct
{
type 1;
type 2;
}stu1, stu2;


Example of structure without tags:-
 void main()
 {
 struct
 {
 int roll;
 char name[10];
 }stu1,stu2;
 printf(“enter roll of 2 student”);
 scanf(“%d%d”,&stu1.roll,&stu2.roll);
 printf(“enter name of two student”);
 scanf(“%s%s”,stu1.name,stu2.name);
 printf(“%d%d”, stu1.roll,stu2.roll);
 printf(“%s%s”,stu1.name,stu2.name);
 getch();
 }