As you know though structure we can process data record by
record that is why structure is called user defined data type. In some specific
case you nested structure where a structure is inside of a structure. For example
when process a student record with their dob. Take a look on following example.
#include<stdio.h>
#include<conio.h>
#include<string.h>
typedef struct
s
{
int roll;
char
name[10];
struct d
{
int
dd,mm,yy;
}dob;
}student;
void main()
{
student stu;
clrscr();
stu.roll=101;
strcpy(stu.name,"Sona");
stu.dob.dd=15;
stu.dob.mm=5;
stu.dob.yy=1995;
printf("\n\nStudent
Detail\n\n");
printf("Roll\t%d",stu.roll);
printf("\nName\t%s",stu.name);
printf("\nDate
of Birth %d/%d/%d",stu.dob.dd,stu.dob.mm,stu.dob.yy);
getch();
}
No comments:
Post a Comment