PDA

View Full Version : c++ programming question


smilingtiger
05-30-2011, 09:31 PM
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 <iostream>
#include <fstream>
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.

mikesal57
05-31-2011, 01:44 PM
you might try paceadvantage.com

theres more programmers there than here

Ted Craven
05-31-2011, 04:09 PM
Hi,

I second Mike's advice. You may also wish to try a Private Message to member 'The Programmer', Randy Kovach, who I believe currently develops software in C++. I myself don't use that language.

Good luck!

Ted

smilingtiger
06-04-2011, 04:47 PM
I found the file. In my compiler, when I went to look for the file, the button on the bottom said 'All Known Files' are shown. My file wasn't there in that directory. I assumed that I was being shown 'ALL' files. I wasn't. I clicked the arrow on the button on the bottom; then I clicked 'All files'. My file was in there.

TheProgrammer
06-04-2011, 10:15 PM
No, I code in C#, haven't used C++ for years.