C
chandanlinster
Consider the following program:
/*********************************************************************************/
#include <stdio.h>
int
main()
{
struct name_struct {
int i;
char ch;
};
printf("sizeof(struct name_struct) = %d\n", sizeof(struct
name_struct));
return 0;
}
/***********************************************************************************/
OUPUT
sizeof(struct name_struct) = 8
Since I am using a 32 bit compiler, the output according to me has to
be
sizeof(int) + sizeof(ch) = 4 + 1 = 5
why is the compiler allocating 3 extra bytes.?
Can anybody explain why this is happening.
/*********************************************************************************/
#include <stdio.h>
int
main()
{
struct name_struct {
int i;
char ch;
};
printf("sizeof(struct name_struct) = %d\n", sizeof(struct
name_struct));
return 0;
}
/***********************************************************************************/
OUPUT
sizeof(struct name_struct) = 8
Since I am using a 32 bit compiler, the output according to me has to
be
sizeof(int) + sizeof(ch) = 4 + 1 = 5
why is the compiler allocating 3 extra bytes.?
Can anybody explain why this is happening.