Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sizeof: Operator or Function? [duplicate]

Tags:

c

sizeof

Possible Duplicate:
Why is sizeof an operator?

Why is sizeof supposed to be an operator in C, & not a function?

Its usage seems similar to that of a function call, as in sizeof(int).

Is it supposed to be some kind of a pseudo-function?


1 Answers

Because it's not a function; it's not possible to write a function that can take a type as an argument and return its size! Note also that sizeof is implemented at compile-time, and that the parentheses aren't necessary if you're using it on a variable.

like image 134
Oliver Charlesworth Avatar answered Jan 02 '26 00:01

Oliver Charlesworth