I tried a code like this

#include <stdio.h> 
int main()
{
    enum a { b, c, d, e,}f;
    printf("The stack top is near %p\n", &(f = e) );
    return f;
}

and got message :
error: lvalue required as unary ‘&’ operand
I use gcc4.3.2.

and I had tried :

#include <stdio.h> 
int main()
{
    enum a { b, c, d, e,}f;
    f = e;
    printf("The stack top is near %p\n", &f);
    return f;
}

there's no error in this way.

In C, the assignment operator returns an rvalue.
In C++ it returns an lvalue, so your first example should work.
(Look up lvalue, rvalue if you don't know what they are.)

In C, the assignment operator returns an rvalue.
In C++ it returns an lvalue, so your first example should work.
(Look up lvalue, rvalue if you don't know what they are.)

thanks for your reply .

but the first example can't work,I had tried.

even the code below makes error in my system, I'm confused.

#include <stdio.h>
int main()
{
int f,e;
f = 0;
e = 1;
printf("The stack top is near %p\n", &(f = e) );

return 0;
}

error: lvalue required as unary ‘&’ operand

Re-read my last post carefully.
In C it will NOT work.
In C++ it WILL work.
Here's a minimal program.
Compile it in C, then in C++ to see the difference. int main() { int i; &(i = 1); }

Re-read my last post carefully.
In C it will NOT work.
In C++ it WILL work.
Here's a minimal program.
Compile it in C, then in C++ to see the difference. int main() { int i; &(i = 1); }

Thank you!

This question has already been answered. Start a new discussion instead.