error: called object is not a function or function pointer

前端 未结 2 819
情书的邮戳
情书的邮戳 2021-01-27 05:01

I have the following code:

  z=x-~y-1;
    printf(\"%d\",z);
  z=(x^y)+2(x&y);
    printf(\"%d\",z);
  z=(x|y)+(x&y);
    printf(\"%d\",z);
  z=2(x|y)-(x         


        
相关标签:
2条回答
  • 2021-01-27 05:49

    Change

    z=(x^y)+2(x&y);
    

    to

    z=(x^y)+2*(x&y);
    

    and

    z=2(x|y)-(x^y);
    

    to

    z=2*(x|y)-(x^y);
    

    You need the multiplication operator if multiplication is what you intended.

    0 讨论(0)
  • 2021-01-27 05:54

    As for what the error means: 2(x&y) tells the compiler to call the function 2, passing x&y as an argument (just like printf("hi") means "call printf and pass "hi" as an argument").

    But 2 isn't a function, so you get a type error. Syntactically speaking, whenever you have a value followed by (, that's a function call.

    0 讨论(0)
提交回复
热议问题