Consider
struct abc
{
int a;
int b;
};
What is the difference between sizeof(struct abc) and sizeof(struct abc*) ?
In your example, if you print the result of the two sizeof() operations, they will both probably be the same (it depends on your system), but that's a coincidence. You can more clearly see the difference if you change the size of the struct.
#include <stdio.h>
struct abc
{
int a;
int b;
int c;
};
int main(int argc, char *argv[])
{
printf("sizeof(struct abc): %ld\n", sizeof(struct abc));
printf("sizeof(struct abc *): %ld\n", sizeof(struct abc *));
return 0;
}
This will print (again, depending on your system, but this is what you'll get on 64-bit unix):
sizeof(struct abc): 12
sizeof(struct abc *): 8
And from that you can guess the difference: the first one is showing you the size of the structure, and the second is showing you the size of a pointer.
The first sizeof will return the size of the struct, the second returns the sizeof a pointer on your computer (probably 64-bits).
It's harder to guess what the first sizeof will return, because struct's can have padding and/or alignment constraints that varies from compiler to compiler or from ABI to ABI.
sizeof exprandsizeof(type)(whereexpris any expression, and type is a typename) (in your case: both cases are of the formsizeof(type), but with different types)