How to access nested structure members in C C++ Linux

#include<stdio.h>
#include<memory.h>
struct employee
{
int id;
char name[10];
struct dob
{
int day;
int month;
int year;
}d;
};

int main()
{
struct employee e1;
//struct dob dd;//can decalre but cant use
e1.id=1000;
strcpy(e1.name,"LealMitra");
e1.d.day=10;
e1.d.month=7;
e1.d.year=2014;

printf("Employee details:\n");
printf("id=%d, name=%s, dob=%d-%d-%d \n",e1.id, e1.name, e1.d.day,e1.d.month,e1.d.year);

return 0;
}
/****************OUTPUT
Employee details:
id=1000, name=LealMitra, dob=10-7-2014
*****************/

No comments:

Post a Comment