No, the C standard defines this behaviour. It is known as short-circuit evaluation.doc-helmut wrote:I won't bet, maybe it's a compiler optimization option....hergipotter wrote:yes, that's it. At least it's true for some other languages, i'm not 100% sure for C...muntoo wrote: Also, I'm not sure, but won't the right side of the||
operator not be evaluated, if the left side is true? (There's no further need to evaluate the right side, if the first one is already true.)
obfuscated C code
-
- Posts: 27
- Joined: 29 Sep 2010, 19:34
- Location: Denmark
- Contact:
Re: obfuscated C code
-
- Posts: 27
- Joined: 29 Sep 2010, 19:34
- Location: Denmark
- Contact:
Re: obfuscated C code
The subtraction is irrelevant, as it has no side effect (unlike the decrement). I am pretty sure it was only put in to get a nice visual effect (and make the code look more complicated).hergipotter wrote:First, F is decremented, then it is checked if it's positive. If yes, then the second statement is not processed because of the OR operator. If not, then OO is decremented and is substracted from F. I have to admit that i don't really know what the substraction is for...
Re: obfuscated C code
I saw it here. Apparently, it's 'more portable'.doc-helmut wrote:and what's the advantage to use size_t instead of simply (and explicitely) int or char or long?
@bullestock I knew something like that was in the standards (heard it at StackOverflow), but I couldn't remember what it was called.
Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE
Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
Who is online
Users browsing this forum: Ahrefs [Bot] and 0 guests