Why does sizeof(x++) not increment x?

前端 未结 9 1760
清酒与你
清酒与你 2020-11-22 09:36

Here is the code compiled in dev c++ windows:

#include 

int main() {
    int x = 5;
    printf(\"%d and \", sizeof(x++)); // note 1
    print         


        
9条回答
  •  余生分开走
    2020-11-22 10:12

    sizeof is a compile-time builtin operator and is not a function. This becomes very clear in the cases you can use it without the parenthesis:

    (sizeof x)  //this also works
    

提交回复
热议问题