100% prog to know how much memory struct variable takes
/* program to understand how memory is alloted for strutures*/
#include <stdio.h>
#include<stdlib.h>
void main()
{
struct date
{
int day, month, year;
char week_day;
}d[3]; //to store three dates
int i;
for(i=0;i<3;i++)
{
printf("\n starting addresses of d[%d].day=%u, d[%d].month=%u,d[%d].char=%u",i,&d[i].day,i,&d[i].month,i,&d[i].week_day);
}
printf("\n starting address of d[0] is %u and d[1] is %u", &d[0], &d[1]);
printf("\n size of 1 structure variable=%d",sizeof(d[0]));
}
#include <stdio.h>
#include<stdlib.h>
void main()
{
struct date
{
int day, month, year;
char week_day;
}d[3]; //to store three dates
int i;
for(i=0;i<3;i++)
{
printf("\n starting addresses of d[%d].day=%u, d[%d].month=%u,d[%d].char=%u",i,&d[i].day,i,&d[i].month,i,&d[i].week_day);
}
printf("\n starting address of d[0] is %u and d[1] is %u", &d[0], &d[1]);
printf("\n size of 1 structure variable=%d",sizeof(d[0]));
}
కామెంట్లు
కామెంట్ను పోస్ట్ చేయండి
దయచేసి మీ సలహాలను సూచనలను స్పష్టంగా పేర్కొనగలరు. plz see that ur comments are 'acceptable' in a value based society.