lvalue required as increment operand error

后端 未结 4 2236
故里飘歌
故里飘歌 2020-12-06 12:22
#include 

int main()
{
   int i = 10;
   printf(\"%d\\n\", ++(-i)); // <-- Error Here
}

What is wrong with ++(-i)?

4条回答
  •  庸人自扰
    2020-12-06 12:58

    The ++ operator increments a variable. (Or, to be more precise, an lvalue—something that can appear on the left side of an assignment expression)

    (-i) isn't a variable, so it doesn't make sense to increment it.

提交回复
热议问题