Not able to understand error condition wrt lvalues

前端 未结 3 670
小蘑菇
小蘑菇 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:21

    a++, as you may know, returns a temporary with the value of a prior to incrementation. And you can't take the address of a temporary for the rather good reason that it'll die at the end of its expression (and thus before you manage to do anything with it).

提交回复
热议问题