//output.open("C:/Users/Muhammad/Desktop/scores.txt");
if (!output)
cout << "error";
output << "any word" << endl;
output.close();
cin.get();
}
I have made the location of the project directory in the desktop but still the file is not created nor opened. when I compile the code it gives success but console window display "error".
first off you have to specify what kind of file you want(txt, bi, exe)
like this
1 2 3 4 5
ofstream output;
output.open("file.txt");
output << "write this cuz i told you to";
output.close();
//this makes, opens, writes, and then closes a txt file
once that is done open file explorer,
find Windows (C:)
open the file that says users
then open the file that has your account name on it
in that should be a file that says source
in that should be one that says repos
in that will be your VS source files. select the one that you created the file in, and it should be in there.
specify the exact folder for a quick test..
output.open("c:/someplace/you/desktop/project/etc/file.txt"); //you need to fill in the path yourself for your exact machine.
if that does not work, your program may lack permission to write to your desktop; you may need to make a dump folder in c:\ and write there, or move the project (this can explode if you had hard paths in it anywhere) somewhere that it does have permissions.
there remains an option that it wrote it somewhere unexpected.
you can do dir/s filename to search for it quickly