Why if I declare following struct :

typedef struct node 
    bool check;
    node* children[27];

and now if I create a variable containing this struct :

node* var;

and now if I check the size using the sizeof I am going to get different value for the variable and for the struct itself

sizeof(var) = 8 bytes

(Do not understand why this is not 224 as well, as it is same struct right? So possibly should inherit its size as well?) but

sizeof(node) = 224 bytes

(I understand why 224 in here)


When you declare node* you are not declaring a variable of type struct node. Rather, you are declaring a pointer-to-node. A pointer is just a memory address. This is why, when you check the sizeof() your pointer, you're seeing 8 bytes instead of 224.

By the way, if this answers your question, please let me know by clicking the green check mark. Otherwise, this could turn into a zombie question, forever haunting the forum.

  • 1
    Thank you. This definitely answers my question :) – kamilucha123 Sep 2 '16 at 18:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .