Not able to understand error condition wrt lvalues

前端 未结 3 671
小蘑菇
小蘑菇 2021-01-22 02:05

I am a beginner in programming and was trying out some combinations.

#include


int main()
{
int a=5;

printf(\"%d\",&a); // STATEMENT 1
print         


        
3条回答
  •  既然无缘
    2021-01-22 02:17

    a++ increments your a and returns the old value of a. The & operator returns the address of a variable. But the returned old value of a doesn't have an address. It's a very temporary thing, not an lvalue. That's why you can not take the address of it.

提交回复
热议问题