So I want to make my program create a file and read/write in that file in a custom directory, preferably in the %appdata% (C:\users\< name >\appdata\roaming)
How do I do this?
I tried:
#include <iostream>
#include <fstream>
using namespace std;
int main(){
fstream inFile("/myFolder/myFile.txt", ios::in | ios::out | ios::app);
return 0;
}
But how do I get it in the %appdata% folder? Do I use the 'system()' function?
For an example:
#include <iostream>
#include <fstream>
using namespace std;
int main(){
fstream inFile("/myFolder/myFile.txt", ios::in | ios::out | ios::app);
system("MOVE C:\\myFolder %appdata%");
return 0;
}
Like. . . you know, this works but I feel like there's a more efficient way/better way. Also I feel like sometimes on some different computers, the 'system()' function might cause a bug. . .