My coding environment: the compiler is Microsoft Visual Studio C++ 2008.
Okay, I have two files by the way, say, a.exe and b.exe. Both of them are Win32 console application. What I’m trying to do is, when I open b.exe and press a button there, it’ll execute a.exe.
But strangely, when I do that, a.exe didn’t run as it should be. It encounters an error which is caused by: when a.exe tried to fopen a x.dat file, fopen returned a NULL value. I’ve tried to change that fopen with fopen_s, but I didn’t succeed either.
The strange thing is that: when I execute a.exe by double-clicking it, it runs PERFECTLY. But when I invoke a.exe with b.exe, the fopen and fopen_s functions didn’t work as it should be. And I’ve also tried invoke a.exe with a Java file, with the same result.
Is there anything that I could do to fix this?
Make sure when you run a.exe invoking from b.exe that you are using the correct working directory or that the file path that you provide to fopen has a full path.