Wednesday, 16 January 2013

Example on Nested Structure in c

#include
struct Addr
{
int streetno;
char city[10];
char state[20];
int zipcode;
};
struct Student
{ int rno;
char sname[20];
int smarks;
int age;
struct Addr a;
};
struct Student carr[]={{1,"Fasi",100,50,
{10,"Hyderabad,"Telengana",500027}}};
void main()
{
struct Student *sptr;
struct Addr b={15,"Vizag","Andhra",500058};
sptr=carr;
sptr->a=b;
printf("%s",sptr->a.state);
}

No comments:

Post a Comment