Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@asgs The decrement is evaluated first. So i is decremented and then the value is subtracted from i (which again, should already be decremented). Thus it should be 0
-
kraator4115y@Mvzes That's why this code has undefined behavior in C. A variable cannot get updated more than once within a sequence point. Different compilers may generate different code for this.
-
asgs112755y@12bitfloat I was merely explaining why it was 1 in this case. It is clearly a UB.
Such kind of code can and must only appear in pointless puzzles -
Tarak311175yit seems to increment the number, anyway I don't fucking care !!!!. Why anyone would do that... I yet to get job but anyone use this in real world? Why they ask this kind of questions in interview?
-
@Tarak311 Maybe the reason you don't care has something to do with you not having a job
-
kraator4115y@Tarak311 two possible reasons why they ask this in an interview :
A) they want you to say this code has UB.
B) they are idiots. If they don't know about UB you should look for a different employer 😉.
i -= --i
joke/meme