#include <stdio.h>
#pragma pack(1)
typedef struct
{
char name[10];
int age;
int class;
char grade;
}stud_s;
int main(void)
{
stud_s s1= {"john" ,10, 10, 'A'};
printf("%ld \n",sizeof(stud_s));
return 0;
}
In the above structure the name is reserved 10 bytes. And the name "john" is 4 bytes so when I use #pragma
the size of structure should be 13. Instead the size resulted in 19 bytes. Could anyone have a look at my code? Any help would be appreciated.