- Why is sizeofgiving the wrong output?
- What is meant by void pointer? Why is it 4 bytes?
In this code:
struct s1
{
    int p;
    void *q;
    char r;
};
struct s2
{
    int p;
    char r;
    void *q;
};
int main()
{
    struct s1 s;
    struct s2 r;
    printf("%d %d",sizeof(s),sizeof(r));
    printf("\n");
    printf("%d %d %d",sizeof(int),sizeof(char),sizeof(void*));
    return 0;
}
I am getting output as 12 but I think sizeof should give 9 as answer.
What is this padding I have heard about in many posts?
 
     
    