ofstream example not working?

1
2
3
4
5
6
7
8
9
10
11
12
// basic file operations
#include <iostream>
#include <fstream>
using namespace std;

int main () {
  ofstream myfile;
  myfile.open ("example.txt");
  myfile << "Writing this to a file.\n";
  myfile.close();
  system("PAUSE");
}


if no one recognizes this, it's from this website. I've been going back through C++ and don't know the if/ofstream things..

Anyway, although this gets no errors it isn't outputting the
"Writing this to a file" string.

Does anyone know why this is happening?
Last edited on
got to xoax.net, he has the best tutorials on this subject
Topic archived. No new replies allowed.