[Coco] Re: Preparing for a job which requires knowledge of C

Rod Barnhart rod.barnhart at gmail.com
Sun Apr 16 12:50:39 EDT 2006


On 4/16/06, doctorx0079 <doctorx0079 at buckeye-express.com> wrote:
>
> > What is the difference between main() in a C program, and main() in a
> C++
> program?
>
>
> In C you've got
>
> void main()
> {
> . .
> }
>
> In C++ you've got
>
> int main()
> {
> . .
>         return(SOME_INT);
> }
>
> where SOME_INT is 0 or some other integer.
>

FWIW, that is incorrect. The second example is just as valid in C as C++.
The value returned by main can be used by the OS. For example, in DOS, the
return value can be checked (usually via batch file) by checking the
errorlevel, and different actions can be taken based on that value. Back in
the day, I got pretty good at DOS batch programming, and if there wasn't
something built in that I needed, hacking together a quick utility in C for
what I needed to check.


--
Rod Barnhart aka Wintermute (http://www.nitemarecafe.com)



More information about the Coco mailing list