[A83] Re: C(++) programming
[Prev][Next][Index][Thread]
[A83] Re: C(++) programming
> i would think that "main()" returns an error because the prototype of the
> function is not defined.
No. If you don't specify a return value, then it defaults to int. In C,
this is legal to do. In C++, ANSI forbids declaring a function with no
return type. It is of course not good programming practice in either case.
> return 0;
> - returns 0 for completed successfully
> - if you have error handlers you might want to return something else
>
> - this is typically flip flopped for unix systems
What are you talking about? It is standard for a process to return zero if
no error occured, or a non-zero value indicating an error condition. Most
libc calls that return a value will return zero if an error occured (malloc
or fopen, for example), instead of a meaningful result. The actual error
value is stored elsewhere (in errno).
References: