create file not working.

I've copied the example from the book exactly; still not working. here's the code:

1
2
3
4
5
6
7
8
9
10
ifstream inFile;

	inFile.open("reservationLog.txt");
	if(inFile.fail()){
		cout<<"File unsuccessfully opened."<<endl
			<<"Please check to see if file exists."<<endl;
		exit(1);
	}

	cout<<"\n the file has been successfully opened for reading."<<endl;
What is wrong?
You cannot compile, or what?
when it compiles, it shows unsuccessfully opened and exits
create file not working.


This isn't how to create a file. This is how to read from a file.
how would i go about creating one?
sorry i'm new at this.
ofstream myfile ("example.txt");
got it thank you.
Topic archived. No new replies allowed.