S
sangeeta chowdhary
I am not able to understand why this code giving output 4 in gcc?
According to my knowledge,enum members are integers and they are
automatically assigned
integer values in sequence starting from zero,if we initialize any
enum variable then followed members start from initialized value plus
1.
Its means ,enum members are given memory then how come i am getting 4
always for any set of members?
#include<stdio.h>
int main()
{
enum value{val1=100,val2,val3,val4,val5,val6,val7,val8,val9,val10}
var;
printf("%d\n",sizeof(enum value));
return 0;
}
According to my knowledge,enum members are integers and they are
automatically assigned
integer values in sequence starting from zero,if we initialize any
enum variable then followed members start from initialized value plus
1.
Its means ,enum members are given memory then how come i am getting 4
always for any set of members?
#include<stdio.h>
int main()
{
enum value{val1=100,val2,val3,val4,val5,val6,val7,val8,val9,val10}
var;
printf("%d\n",sizeof(enum value));
return 0;
}