Brace with me here. I'm trying to make a few simple, but useful C++ console apps that I want to run by starting them straight from cmd (like DiskPart for example). I have a finished product, compiled by gcc through VS Code powershell. The idea is: I have a main.exe and a data file stored in "veco/data.txt" next to the executable. The code works perfectly well when started from its folder where it was compiled, but when I try to copy it to WindowsApps folder (to be able to start it by typing its name in cmd) it just doesn't work...
Yes I did copy the folder too, I've tried to run it from powershell and I get 0 crash msgs...
Here's the part where I interact with the text file:
string s = _pathToExe + "veco\data.txt";
ifstream is(s);
//i do stuff here
is.close();
where _pathToExe is path to the executable, without the actual name of the executable. ifstream is(s) seems to be the crashing point.
I compiled the code using two commands:
g++ -c <all .cpps>
g++ -o main.exe <all objs>
Can I make this work somehow? Any other suggestions are welcome too.
Note: I've tried copying to other locations, doesn't work there either.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…