"for" loops (was Re: C++ vs. Modula2)
Geoff Rimmer
geoff at warwick.UUCP
Fri Feb 3 03:56:22 AEST 1989
In article <6419 at polya.Stanford.EDU> crew at Polya.Stanford.EDU (Roger Crew) writes:
>Here's a quiz:
>How would you write the following in C?
>
> VAR a, b, c : Char;
> ...
> FOR c = a TO b DO ... END;
>
>You can even assume that the body of the loop affects neither a nor b.
>Hint: the answer is *not*
>
> char a, b, c;
> ...
> for (c = a; c <= b; ++c) { ... }
>
>(just try a = 0 and b = 255 in the case of 8 bit chars).
>--
What a stupid question. If you are going to count from 0 to 255, you
wouldn't use char in the first place - you'd use unsigned char, or
int. I can't see what you're getting at, at all.
Go back to writing Fortran. Let the *real* programmers use C. :-)
>Roger Crew Copyright 1989 -- All Rights Reserved. (so there!)
>Usenet: {arpa gateways, decwrl, uunet, rutgers}!polya.stanford.edu!crew
>Internet: crew at polya.Stanford.EDU
------------------------------------------------------------
Geoff Rimmer, Computer Science, Warwick University, England.
geoff at uk.ac.warwick.emerald
"I didn't ask to be made. No consulted me or considered my
feelings in the matter, not that anyone considered that I
might *have* feelings. After I was made, I was left in a
dark room for six months, and me with this terrible pain in
all the diodes down my left side. My one and only true
friend was a small rat. One day it climbed into a cavity of
my inner leg and died. I've a horrible feeling it's still
there." - Marvin, The Hitch Hiker's Guide to the Galaxy.
------------------------------------------------------------
More information about the Comp.lang.c
mailing list