how much memory structure take in code
I am confused with structure size
Code:
#include <stdio.h>
struct point
{
int x;
char y;
}s1;
int main()
{
s1.x = 20;
s1.y ='A';
printf("s1.x= %d \n", s1.x);
printf("s1.y= %c \n", s1.y);
printf("Size of Structure : %d \n", sizeof(s1));
return 0;
}
s1.x= 20
s1.y= A
Size of Structure : 8
one integer variable takes 4 bytes and one char variable takes 1 bytes so total size of structure should be 5 bytes but program gives 8 bytes
so how much memory structure take in code ?