Mail Archives: djgpp/1997/05/10/20:32:26
Ross Litscher wrote:
>
> Erik Max Francis wrote:
> >
> > Chris Croughton wrote:
> >
> > > > first, this is pure and simple C. in any case, void is not a valid
> > > > return type for main.
> > >
> > > Incorrect. Void is a perfectly good return type for main.
> >
> > Wrong. ANSI C standard, section 5.1.2.2.1.
> >
> > > > main has to return an int.
> > >
> > > No it doesn't. It only needs to generate any specific exit value
> > > if you will be using the result to test the state of the program
> > > afterwards (like in make or with the batch ERRORLEVEL).
> >
> > No; the standard dictates that main must conform to one of the following
> > two prototypes:
> >
> > int main(void);
> > int main(int argc, char *argv[]);
> >
> > > And even
> > > then it's perfectly valid to use exit(n) rather than return.
> >
> > ANSI C 7.10.4.3. Control is returned to the host environment, and
> > successful termination or unsuccessful termination is "returned." This
> > means that from the point of view of a program-executing environment,
> > calling exit makes the program look like it returned from main.
> >
> > > It may be considered, in some places, good /style/ to declare main
> > > as int, but that's a long way from it being an absolute.
> >
> > No. It is an ANSI violation to have main return anything other than int,
> > even if your host environment doesn't do anything valuable with the return
> > values.
> >
> > > Even with -Wall -ansi -pedantic I can't get gcc to complain about
> > > void main...
> >
> > So? Just because a compiler doesn't complain about something doesn't that
> > something ANSI C compliant.
> > --
> > Erik Max Francis, &tSftDotIotE / email / max AT alcyone DOT com
> > Alcyone Systems / web / http://www.alcyone.com/max/
> > San Jose, California, United States / icbm / 37 20 07 N 121 53 38 W
> > \
> > "The future / is right there."
> > / Bill Moyers
>
> Sorry, I didn't mean for my sloppy coding, and using mostly code I found
> on the net, to start a debate. :/
>
> so, the stdio.h was the problem with the rand(). That part of the code
> is what I got off a tutorial, so I assumed it to be correct. as for my
> code for slowing down the program, i should do something like delay(250)
> or something... and for the 'void main(void) y'all confused me a bit.
> should i do something like:
>
> int main()
> {
> ...
> return 0;
> }
>
> remember, newbie here, just trying to clear things up in my mind. I'd
> like to do things correctly.... someday. please be patient.
>
> Ross
oops, i meant stdlib.h for rand()
- Raw text -