write file to directory
Jan 6, 2016 at 6:22am UTC
How do i write to or create a file to a specific directory using fstream?
Jan 6, 2016 at 6:26am UTC
1 2 3 4
fstream file;
file.open("directoryname/filename.ext" ,ios::out);
file << "writing data" ;
file.close();
Jan 8, 2016 at 5:49am UTC
I've tried that method but it doesnt seem to work, it is not creating a file
Jan 8, 2016 at 4:16pm UTC
You should check all error returns from all functions. What errors are you seeing?
Jan 8, 2016 at 5:12pm UTC
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.
Jan 9, 2016 at 5:38am UTC
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
Jan 9, 2016 at 2:02pm UTC
Awesome! Please marked this as answered.
Topic archived. No new replies allowed.