coperatorssizeof

Why is sizeof considered an operator?


Why is sizeof considered an operator and not a function?

What property is necessary to qualify as an operator?


Solution

  • Because the C standard says so, and it gets the only vote.

    As consequences:

    A function would differ on all those points. There are probably other differences between a function and a unary operator, but I think that's enough to show why sizeof could not be a function even if there was a reason to want it to be.