Fstream Undeclared Identifiers Error

I'm pretty new to programming, so sorry if this comes across as stupid, but hey... I looked around for a solution before posting here like a good newb, but found none. :(

I'm trying to compile this simple bit of code in MSVC++ 2008 but it comes up with errors saying 'ofstream' and 'file' are undeclared identifiers. S: Where am I going wrong?/What am I missing? I tried to compile several examples from other sites and tutorials and they all come up with similar errors.

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <fstream>

int main() {


	ofstream file;
	file.open("test.txt");
	file << "Hello world.";
	file.close();

	return 0;
}


Thank you in advance!
As you're not using namespace std; // which i prefer not to use to you have to write std::ofstream file; instead
Oh I see! Thank you!!! :)))
Topic archived. No new replies allowed.