c - Logic behind sizeof operator -
this question has answer here:
- how sizeof work int types? 3 answers
- how sizeof(array) work 5 answers
here have sizeof
operator in c
. returning size of datatypes,
printf("%d",sizeof(some datatype));
and result 4 (os dependent).
i want know how calculating. logic behind operator. if ask write code sizeof
operator. answer?
note : want know how sizeof
written code capable calculate size.
as may not able ask question properly,i trying here again.
write 1 function can use instead of sizeof operator.
the compiler knows size of types, has or not able generate code correctly. information used sizeof
operator.
also note sizeof
not function being called @ runtime, it's operator evaluated during compilation.
Comments
Post a Comment