So I am a beginner to C. I was going through text about l-value and r-value when I came across this in one of my study materials:
"We talk about l-value and r-value with respect to assignment operator =. The only operator which gives a value back is the dereferencing operator."
This confuses me because don't the increment/decrement operators also give a value? Then how is dereferencing the only operator that gives a value back?
I think this is a typo and is supposed to say
The only operator which gives an l-value back is the dereferencing operator.
It isn't strictly true. For example, the []
, .
and ->
operators also give back lvalues (the standard spells it without a hyphen) so that you can write
a[5] = 17;
s.x = 42;
p->y = 17;