Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 i/o file error
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Nick




PostPosted: 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"
Sponsor
Sponsor
Sponsor
sponsor
CodeMonkey2000




PostPosted: 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.
Nick




PostPosted: 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
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: