你能解释一下为什么在下面的代码中出现编译时错误吗
can you explain why compile time error in the below code
为什么我在下面给出的代码中出现错误....
#include <stdio.h>
void foo(int*);
int main()
{
int i = 10;
foo((&i)++);(in this line error shows like this) //error: lvalue required as increment operand
}
void foo(int *p)
{
printf("%d\n", *p);
}
The address-of operator produces the non-lvalue address of its operand, suitable for initializing a pointer to the type of the operand.
并且来自 Increment/decrement operators:
The operand expr of both prefix and postfix increment or decrement must be a modifiable lvalue of integer type (including _Bool and enums), real floating type, or a pointer type.
简单地说,&
运算符没有为 ++
运算符生成合适的对象。
为什么我在下面给出的代码中出现错误....
#include <stdio.h>
void foo(int*);
int main()
{
int i = 10;
foo((&i)++);(in this line error shows like this) //error: lvalue required as increment operand
}
void foo(int *p)
{
printf("%d\n", *p);
}
The address-of operator produces the non-lvalue address of its operand, suitable for initializing a pointer to the type of the operand.
并且来自 Increment/decrement operators:
The operand expr of both prefix and postfix increment or decrement must be a modifiable lvalue of integer type (including _Bool and enums), real floating type, or a pointer type.
简单地说,&
运算符没有为 ++
运算符生成合适的对象。