delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/05/13:24:48

From: Michael Rowley <stardog AT serv DOT net>
Newsgroups: comp.lang.c++,comp.os.msdos.djgpp
Subject: Re: CIN COUT
Date: Wed, 05 Mar 1997 08:23:30 -0800
Organization: ServNet Internet Services
Lines: 60
Message-ID: <331D9E02.78D4@serv.net>
References: <331BC0D5 DOT 5CB AT aracnet DOT com> <5fjr8f$3ko AT whitbeck DOT ncl DOT ac DOT uk>
NNTP-Posting-Host: goldendawn.serv.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Dazzling Dazz wrote:
> 
> Can Someone please tell me what is wrong with the following program.
> I try to compile it on djgpp but I get 'undeclared' or something error.
> Maybe I don't have the right iostream.h file?
>    #include <iostream.h>
>    main()
>    {
>    cout << "Hello, World";
>    }
> Thanks in advance.  - bardito AT aracnet DOT com
> 
> +++++++++++++++++++++++++++
> 
> wouldn't you have to declare main as a void or int? Like this:
> 
>  void main()
>  {
>    ...
>  return;
>  }
> 
> OR
> 
>  int main()
>  {
>    ...
>  return 0;
>  }
> 
> I've never used that compiler so this is probably wrong, sorry.

I havent used that compiler yet BUT i think i know whats wrong, first of 
all, in most cmopilers main() defualts to  int main(void) So by just 
having the line main() chances are your compiler reads it as int main 
(void)  SO first off i would add the line  return 0;  to the end of your 
file.... Copy this code and try to compile it....first...

#include <iostream.h>

int main(void)
{
	cout << " Hello, World\n";

	return 0;
}

If you get an undefined COUT when you compile... check the file 
extention and see if its   .cpp OR .c or .gxx or .c for unix. Djgpp if i 
remember correctly is a c/c++ compiler so there verywell could me a 
option to have it use either the .c or .cpp nameing system some 
compilers like borland will automaticly figure it out for ya, but some 
of the older version don't... if the above program doesnt work, and you 
copy it excatly, then the problem lies in an internal switch that you 
must change... < in borland if you have the nameings set wrong it will 
POP you into the iostream.h file and you will be wondering <THere isnt 
anything wrong> but that is what it is.... =) anyhow good luck with 
it.... and take care....

Stardog AT serv DOT net

- Raw text -


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