
-----------------------------------
Nick
Wed Nov 14, 2007 8:15 pm

i/o file error
-----------------------------------
i am using Dev C++ version 4.9.9.2 and i am using #include
#include
#include
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"

-----------------------------------
CodeMonkey2000
Wed Nov 14, 2007 8:30 pm

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.

-----------------------------------
Nick
Wed Nov 14, 2007 8:37 pm

RE:i/o file error
-----------------------------------
thanks i got rid of .open and added () to .close and it ran
