I have a CLI app and I want it to be able to be called in any directory (e.g. C:\Users\Me> CLI_App.exe {args}
or some\other\path> CLI_App.exe {args}
) but I want the files to be saved into the same place of the exe instead of the directory of where the app is called. I would prefer the solution to be cross platform.
I have tried doing
cout<<argv[0];
(to see if it outputs the path of the file so that I could make a file path of argv[0] + "exaample.txt"
)
but all I get as the output is just CLI_App.exe
or sometimes true
Replying to yunnosch, I want the files to stay in the same place. This means that if I use the app with the terminal from a different folder, I'd like it to open the exact file that the user put in. I don't want the app to get confused, thinking the file doesn't exist in the current folder and then creating a new one. Even if a file with the same name exists in another folder, I want the app to recognize and use the correct one.