Hi all!
Is there anyone out there who understands the meaning of this synthax ?
??? ??? ???
xincr = x2 > x1 ? 1 : -1;
thanks!
That's C's infamous ternary operator. It is just a shorthand IF statement.
if(x2 > x1)
xincr = 1
else
xincr = -1;
The ternary operator can lead to the most unreadable code that C programmers can write. Especially when they nest it.
Paul.
Thanks Paul!
QuoteThe ternary operator can lead to the most unreadable code that C programmers can write. Especially when they nest it.
Unlucky me! i often stumble on this king of code ;D