// FUNCTION: SAVE MELODIES TO A TXT FILE..
void SAVE_TXT()
{
string TXT_NAME; // String value for name of txt file to save to..
cout << "\nPlease enter the desired txt file name: ";
cin >> TXT_NAME;
string FULL_TXT_PATH = ( "../MIDI_and_TXT_Files/" + TXT_NAME + ".txt");
cout << "Filename: " << FULL_TXT_PATH;
ofstream TXT_FILE (FULL_TXT_PATH, ofstream::out);
// CHECK THE STATUS OF THE TXT FILE..
// IF: TXT FILE NOT OK..
if (!TXT_FILE)
{
cout << "\nError opening output file..\n";
return;
}
// END IF..
// IF: TXT FILE IS OK..
if (TXT_FILE)
{
cout << "\nWrite was successful\n";
FORMAT_TXT();
}
else cout << "\nWrite Failed..\n";
}
// END FUNCTION..
I've changed the folder name to "../MIDI_and_TXT_Files/" so its a bit more program / platform friendly..
But alas, its still not working. The error trap works and states "Error opening output file" but i just can' see why it won't work. It complies ok and no errors, just the file open / creation whatever part is not doing as intended. It's gonna be something obvious i know it haha..
Does the folder "MIDI_and_TXT_Files" already exist? If not, you should create it before running the program.
You also need to be aware that when using a relative path, first of all you need to be sure which is the starting location. This is the "working directory" of the program - it may be the same as the location of the executable program but need not be, especially if the program is run through an IDE.
...so not including a path and it works, saving it in the same directory as the .cpp file etc so that works but how do i get it to save in the other folder?