Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
msarnoff
on Dec 15, 2011
|
parent
|
context
|
favorite
| on:
Understanding lvalues and rvalues in C and C++
Interesting C++ tidbit: the ternary operator can yield an lvalue, like so:
int foo = 0, bar = 0; (cond ? foo : bar) = 8;
This doesn't work in plain C.
koenigdavidmj
on Dec 15, 2011
[–]
But it does with pointers in C:
int foo = 0, bar = 0; *(cond ? &foo : &bar) = 8;
Consider applying for YC's Fall 2026 batch!
Applications
are open till July 27.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: