I have started using the fstream class in C++ to create text files for input and output. Whenever I try to instantiate an fstream object using the following code
Expand|Select|Wrap|Line Numbers
- fstream data("c:\\sine.txt",ios_base::in|ios_base::out);
- if(!data){
- cerr<<"Failed to open data\n";
- }
- data.close();
Expand|Select|Wrap|Line Numbers
- ofstream data_one("c:\\sine.txt");
- if(!data_one){
- cerr<<"Failed to open data_one\n";
- }
- data_one.close();
- fstream data("c:\\sine.txt",ios_base::in|ios_base::out);
- if(!data){
- cerr<<"Failed to open data\n";
- }
- data.close();