I'm trying to find out the size of structure variable. As per the code sizeof structure should be 28, but the result shows 8 and name is given more than 20 characters, but it is printed fine. I'm unable to understand this behaviour, can anyone help me out?
Iam using DevC++ to compile my C code.
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef struct
{
    char name[20];
    int identity;
    int number;
}S;
int main()
{
    S *s=(S *)malloc(sizeof(S));
    printf("Size of structure is %d \n",sizeof(s));
    strcpy(s->name,"abcdefghijklmnopqrstuvwxyzffjfjfzdabcdefg");
    printf("name is %s and size of name is: %d\n", s->name ,sizeof(s->name));
    s->identity=10;
    s->number=20;
    printf("Identity is %d and size of identity is %d\n",s->identity, sizeof(s->identity));
    printf("Number is %d and size of number is %d\n",s->number , sizeof(s->number));
    return 0;
}
I expect the output of "Size of structure" to be 28,but the actual output is 8.
 
     
    