I doubt this is the problem, but with your compiler it might be necessary for you to explicitly enable output to the file by setting the ios::out bit when opening the file. Try this code:
Code:
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char** argv) {
ofstream MyFile;
//Open file
MyFile.open("example.txt", ostream::out);
if(MyFile.fail()) {
cerr <<"Sorry, I can't open that file for output\n";
return 0;
}
//Write to file
MyFile <<"This should be inside of example.txt" <<endl;
//Close file
MyFile.close();
}
That should create the file and write to it. If it doesn't, it should say it couldn't open the file. Hope that helps