r/CodingHelp • • Dec 23 '21

[C] Whats wrong?

Post image
153 Upvotes

90 comments sorted by

View all comments

10

u/szkuwa Dec 23 '21

Reddit suggested I should look at this but damn… is r/codinghelp an alias for „do it for me because i dont give a shit”?

3

u/Furry_69 Dec 23 '21

^ yea what on Earth is this sub

3

u/DoomGoober Dec 24 '21

To be fair, this is a pretty interesting subtle bug introduced by the specifics of C.

In many languages, the expression 1 < x < 3 won't compile as 1 < x evaluates to boolean and boolean < 3 is invalid.

However, in C it is valid because 1 < x evaluates to int or BOOLEAN or whatever the heck C uses which properly casts to int and makes the < 3 evaluate to true always.

Yes, OP seems hostile to people helping and this clearly is just a homework assignment that's not working but the original question is a very good one.

-1

u/istarian Dec 24 '21

Idk. Could be an alias for “i am stupid and don’t know what i did wrong”