That’s not a real operator. You’ve put a space in “i–” and removed the space in “-- >”. The statement is “while i-- is greater than zero”. Inventing an unnecessary “goes to” operator just confuses beginners and adds something else to think about while debugging.
And yes I have seen beginners try to use <-- and --<. Just stop it.
The sheer number of people that do not expect a joke on this community… (Really, if you are trying to learn how to program pay attention to the one without the Humor on the name, not here.)
I didn’t know why, but *++p bugs me
welcome to C
Perhaps *(p += 1) will be to your liking?
p = 1 x = ++p // x = 2 // p = 2
p = 1 x = p++ // x = 1 // p = 2
++p
will increase the value and return the new valuep++
will increase the value and return the old valueI think
p = p + 1
is the same asp++
and not as++p
. No?(p += 1) resolves to the value of p after the incrementation, as does ( p = p + 1).
Yes.
p++
==p+= 1
==p = p + 1
are all the same if you use it in an assignment.++p
is different if you use it in an assignment. If it’s in its own line it won’t make much difference.That’s the point I was trying to make.
No.
++p returns incremented p.
p += 1 returns incremented p.
p = p + 1 returns incremented p.
p++ returns p before it is incremented.
Much better… but can we make it
*((void*)(p = p + 1))
?How about some JavaScript
p+=[]**[]
?That
*++
operator from C is indeed confusing.Reminds me of the goes-to operator:
-->
that you can use as:That’s not a real operator. You’ve put a space in “i–” and removed the space in “-- >”. The statement is “while i-- is greater than zero”. Inventing an unnecessary “goes to” operator just confuses beginners and adds something else to think about while debugging.
And yes I have seen beginners try to use <-- and --<. Just stop it.
The sheer number of people that do not expect a joke on this community… (Really, if you are trying to learn how to program pay attention to the one without the
Humor
on the name, not here.)Well, I guess nobody expects.