The elements of a structure are always stored in contiguous memory
locations. This can be illustrated as
void main()
{
struct student
{
int roll;
float marks;
char remarks;
};
struct student st={200,60.5,'P'};
printf("\nAddress of roll=%u",&st.roll);
printf("\nAddress of marks=%u",&st.marks);
printf("\nAddress of remarks=%u",&st.remarks);
getch();
}
Output:
Address of roll=65518
Address of marks=65520
Address of remarks=65524
st.roll st.marks st.remarks
200
|
60.5
|
‘P’
|
65518 65520 65524
Comments
Post a Comment