this post was submitted on 09 May 2024
433 points (92.0% liked)

Programmer Humor

32054 readers
1807 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] fluckx 2 points 4 months ago (1 children)

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.

[–] SpaceNoodle 5 points 4 months ago (1 children)

No.

++p returns incremented p.

p += 1 returns incremented p.

p = p + 1 returns incremented p.

p++ returns p before it is incremented.

[–] fluckx 3 points 4 months ago

Right. So i had them the other way around. :D

Thanks for clarifying.