delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/08/12/13:09:20

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <3D57EC78.9060206@unu.edu>
Date: Tue, 13 Aug 2002 02:12:24 +0900
From: =?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?= <zunino AT unu DOT edu>
Organization: UNU Campus Computing Centre
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.1b) Gecko/20020801
X-Accept-Language: en
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: GCC3 problems with C++ fstream
References: <187198960129 DOT 20020812184802 AT familiehaase DOT de>
X-Virus-Check: by UNU Campus Computing Centre (HQmail)

Gerrit P. Haase wrote:

> #include <fstream>
> void main() //the program starts here

main() must return 'int'

> {
> ofstream SaveFile("cygwin.txt");

ofstream lives in the 'std' namespace

> SaveFile << "Hello World, this works with gcc-2 but not with gcc-3!";
> SaveFile.close();
> }

Try this corrected version:

#include <fstream>

int main()
{
  using namespace std;

  ofstream saveFile("test.txt");
  saveFile << "Hello World, this works with gcc-2 but not with gcc-3!";
  saveFile.close();

  return 0;
}

Hope this helps,

-- 
Ney André de Mello Zunino
Media and Technology Laboratory
Campus Computing Centre
United Nations University


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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