GCC3 problems with C++ fstream

Ney André de Mello Zunino zunino@unu.edu
Mon Aug 12 10:30:00 GMT 2002


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/



More information about the Cygwin mailing list