View Single Post
Old 05-30-2011, 09:31 PM   #1
smilingtiger
AlwNW2X
 
Join Date: Jun 2008
Posts: 24
c++ programming question

Hi. I don't know which forum I should post this on, so I posted here.
I've written a program based on MPH. In C++. However, I'm a novice at programming. I haven't created files or done sorting. I get the numbers from my screen and sort manually. I'd like to create files. The question is: How do I do so? I've googled and have come up with info that doesn't seem to work.
Example:

// basic file operations
#include
#include
using namespace std;

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

This does not work. I cannot find a file after running this little
program called 'example.txt'.
I'm not a programmer; I just need to do this.
smilingtiger is offline   Reply With Quote