write file to directory

How do i write to or create a file to a specific directory using fstream?

1
2
3
4
fstream file;
file.open("directoryname/filename.ext",ios::out);
file << "writing data";
file.close();
I've tried that method but it doesnt seem to work, it is not creating a file
You should check all error returns from all functions. What errors are you seeing?
closed account (E0p9LyTq)
I've tried that method but it doesnt seem to work, it is not creating a file


Depending on your development environment and how you start your program the file might not be where you expect it be created.

Visual Studio 2015 file creation changes when you run the program via the IDE or from File Explorer.
my bad it actually does work.
what happened was that the program did not have privileges to folder i was creating it to.
i just changed the privileges and it worked
Awesome! Please marked this as answered.
Topic archived. No new replies allowed.