Computer Science Canada

i/o file error

Author:  Nick [ Wed Nov 14, 2007 8:15 pm ]
Post subject:  i/o file error

i am using Dev C++ version 4.9.9.2 and i am using this tuturial

here is my code
c++:
#include<fstream>
#include<iostream>
#include<string>
using namespace::std;

int main(){
    string text("");
    ofstream a_file.open("example.txt");
    a_file.close;
}


my error is:
C:\Dev-Cpp\io file test.cpp expected primary-expression before "a_file"

Author:  CodeMonkey2000 [ Wed Nov 14, 2007 8:30 pm ]
Post subject:  RE:i/o file error

I think you are missing a parameter for the ofstream deceleration. Try using ios::in or ios::out. And I dont think you need the .open after a_file.

Author:  Nick [ Wed Nov 14, 2007 8:37 pm ]
Post subject:  RE:i/o file error

thanks i got rid of .open and added () to .close and it ran


: