Mail Archives: djgpp/1999/09/05/03:52:08
Damian Yerrick wrote:
> > > #include <iostream.h>
> > > void main (){
> > >     cout << "Hello World";
> > > }
> > > What did I do wrong?
> > In addition to using an illegal return type for main(), it appears
> Illegal return type? Some C/C++ programming books encourage
> a fellow to make main() a procedure. But maybe that's because I
> came from a Macintosh background, and this is DOS.
    I don't think the word "procedure" is correct for C/C++.  That's what they
call functions that don't return values in Basic/Pascal, but if something in C
has a 'void' return type, it is still a function, but that's just being picky.
    If the books encourage you to use 'void' as a return type for main, then
the books are wrong.  The ANSI C/C++ standard requires that the main function
return 'int', under all platforms including Mac's.  I used to use "void
main()" a lot in Borland C, and it didn't mind it, but it was still wrong.
--
     (\/) Endlisnis (\/)
          s257m AT unb DOT ca
          Endlisnis AT HotMail DOT com
          ICQ: 32959047
- Raw text -