Pages

Friday, December 28, 2012

Storage of structures in memory,C Programming


The main point is that structure members are stored in consecutive memory locations.

main()
{
struct student {
char name[20];
int rollno;
float marks;
}stu;
printf("Address of name = %u\n",stu.name);
printf("Address of rollno = %u\n",stu.rollno);
printf("Address of marks= %u\n",stu.marks);
}
OutPut::
Address of name = 2000
Address of rollno = 2005
Address of marks = 2007;
See Below figure more understanding ..!!(Output may be different on different machines)


g2991

No comments:

Post a Comment