Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
#include<iostream>
#include<fstream>

using namespace std;
int main(){

ifstream inputFile;
ofstream outputFile;

inputFile.open ("DataIn.txt");
inputFile.close();
}


The above code run with no error,but it doesnt create the DataIn.txt.
Anything wrong with my code?
Posted
Updated 1-Oct-10 4:57am
v2

You are trying to open an input file which means the open will fail if the file does not exist, it does not create it. Take a look at the documentation for ifstream[^], and ofstream while you are there.
 
Share this answer
 
You have used #include two times but you did not specify any file.
Remove these "#include" lines. And type there #include <fstream.h>.
I hope this works.
GOOD LUCK.
 
Share this answer
 
Comments
tuolesi 1-Oct-10 10:56am    
sorry i miss type in my above question, i did include fstream and iostream.
CPallini 1-Oct-10 14:06pm    
Please don't give wrong advices: STL *.h headers are obsolete.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900