Spot the mistakes

Can anyone help me in spotting the mistakes in this program?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <ifstream>
using namespace std;
int main()
{
	ifstream.outfile;
	open.outfile(myfile.txt);
	cout << "Writing to the file: \n";
	outfile >> "Tom\n";
	outfile >> "Dick\n";
	outfile >> "Harry\n";
	close.outfile();
	return 0;

}


I do not understand why I am not able to run this program =/
Changes in bold:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
	ofstream outfile;
	outfile.open("myfile.txt");
	cout << "Writing to the file: \n";
	outfile << "Tom\n";
	outfile << "Dick\n";
	outfile << "Harry\n";
	outfile.close();
	return 0;

}
Last edited on
also it should be <fstream> without the i in it right?
Ah yes, didn't see that.
Topic archived. No new replies allowed.