delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/05/03:52:08

Message-ID: <37D1DFFA.1E834ACA@unb.ca>
From: Endlisnis <s257m AT unb DOT ca>
X-Mailer: Mozilla 4.61 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: problems compiling c++ in rhide
References: <7qjmhn$o47$1 AT nickel DOT uunet DOT be> <37D0B102 DOT 389529B AT earthlink DOT net> <7qrfmq$qvq$1 AT solomon DOT cs DOT rose-hulman DOT edu>
Lines: 29
Date: Sun, 05 Sep 1999 03:46:01 GMT
NNTP-Posting-Host: 198.164.188.197
X-Trace: news21.bellglobal.com 936503161 198.164.188.197 (Sat, 04 Sep 1999 23:46:01 EDT)
NNTP-Posting-Date: Sat, 04 Sep 1999 23:46:01 EDT
Organization: Sympatico
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019