Re: Programming to Beat the Odds in Gaming



Richard Heathfield wrote:
Greg Herlihy said:

On May 4, 6:18 pm, Ian Collins <ian-n...@xxxxxxxxxxx> wrote:
gcc -Wall -pedantic -ansi basic.c script.c -lm
basic.c: In function 'dofor':
basic.c:870: warning: suggest parentheses around && within ||
basic.c:873: warning: suggest parentheses around assignment used as
truth value
basic.c: In function 'getdimvar':
basic.c:1932: warning: suggest parentheses around assignment used as
truth value
These warnings are bogus.

Without looking anything up, please parenthesise this line in such a way as not to change its meaning:

if(stepval < 0 && initval < toval || stepval > 0 && initval > toval)

After you've done that, you can look stuff up to see whether you got it right. If you did get it right, award yourself a pat on the back, and consider the fact that not every C programmer is sufficiently skilled to follow the above expression properly.

When I see code constructs that I'm not familiar with,
I look them up and in so doing, I learn the language better.
I have no philosophical problems
with code that I write putting anybody else through that.

--
pete
.