delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/04/00:51:12

From: gfoot AT mc31 DOT merton DOT ox DOT ac DOT uk (George Foot)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: CIN, COUT
Date: 4 Mar 1997 03:19:40 GMT
Organization: Oxford University
Message-ID: <5fg4cc$ehc@news.ox.ac.uk>
References: <331B8C40 DOT 11A1 AT aracnet DOT com>
NNTP-Posting-Host: mc31.merton.ox.ac.uk
Lines: 32
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Brian (bardito AT aracnet DOT com) wrote:
: Does Cin and COUT work in djgpp?

Yes.

: I tried a simple program:
: #include <iostream.h>
: main()
: {
:     cout << "Hello, World";
: }
: and It gave me an error saying NOT DECLARED or something like that.
: what am I doing wrong? All help appreciated. - bardito AT aracnet DOT com

You really should give more information - it's difficult to troubleshoot
without knowing the exact error message and command line used.

General points:

1) cin and cout are C++, so you should save your source code
as a .cc file and use gxx to compile it.

2) Your main() function doesn't return; it should (just put `return 0;'
at the end). It is also better to write `int main()' instead of `main()'
(or maybe this is just my personal preference?).

On my system the program compiles as quoted above, using gxx to compile 
and link, without errors or warnings, though.

-- 
George Foot <gfoot AT mc31 DOT merton DOT ox DOT ac DOT uk>
Merton College, Oxford.

- Raw text -


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