I am wanting to create a file in a folder using OFstream. The following lines of code - always Give "Output File could not be created...". No matter what I try.
Eventually I want to replace the JOHN part of the string, with a variable (type String).
Tips would be very much appreciated.
ofstream output_file(".\\Players\\JOHN\\Balance.txt", ios::app); // open the output file for appending
if (!output_file.is_open()) { // check for successful opening
cout << "Output file could not be opened! Terminating!" << endl;
_sleep(1000);
return 1;
}
else{
output_file << getAcctbal();
output_file.close();
return 0;
}
EDIT:
What have is a Players Folder - in that Players folder. for each individual Player I want to have a file (so John) is a Folder in this case. This folder doesn't exist, and is something I am trying to achieve. Thank you very much :-)