James [on his mailserver] wrote:
> why doesn't this work:
> for (c=0; c==9; c++)
> /* something */
If c starts at 0, then the loop condition c==9 is never true, and the
loop is never executed.
> and, is this a Bad Thing...
> for (int c=0; c<10; c++)
> /* stuff */
Looks like a fairly standard loop to me, except that I alwasy use curly
bracets on loops/conditionals. Skipping the bracets gets you in trouble
sooner or later when you update the code and forget to add them..
> And here's something that my C Programming tutor does:
>
> main ()
> {
> /* whatever */
> exit (0);
> }
Thats the old way of doing things, prior to ANSI-C.
> shouldn't it really be
>
> int main ()
> {
> /* things */
> exit (0);
>
> return (0);
> }
If you want to use ANSI-C then you don't need to call exit(). ANSI-C
defines the result of main as the programs exit code, unless terminated
by another way (exit call, killed or what ever).
---
Henrik Nordstr�m