msvc debugger

Started by
6 comments, last by Evil Steve 17 years, 8 months ago
when running my program through the debugger, it will throw and error but loading a file, but not when running from explorer. what do ihave to do?
Advertisement
What error is it throwing?

Dave
ide provides default values and exception handlers

initialize all variables especially pointers

Kuphryn
sorry, i made a typo earlier, what i ment was when it try to load a file it can't find it and exits but can when run the explorer.
sorry if i was unclear
The program working directory is probably another one when you run it from the debugger.
do you have any idea where it is or how to change it?

thanks jason
Its in the project options under debugging. Set it to the same directory that the exe is in.
When you run the program from the IDE, the working directly is set to your project directory, which is usually the folder containing the debug and release folders. When you run the program from explorer, the working directory is set to the current directory.

You can change the working directory in the IDE by going to project settings -> Debugging and changing the "Working Directory" there.
Alternatively, load all your resources using absolute paths instead of relative paths (E.g. "C:\folder\app\data\blah.txt" instead of "data\blah.txt"). You can use GetModuleFileName() to get the filename of your exe, and strip the filename to get the path to your exe.

Quote:Original post by kuphryn
ide provides default values and exception handlers
Just to nitpick: The compiler in debug mode sets the default values, not the IDE. The default values are supposed to be gibberish (At least, a recognisable pattern), so you can notice uninitialized variables. If he runs the debug exe from explorer, the variables will be initialized the same.

This topic is closed to new replies.

Advertisement