Visual Studio调试执行路径

Luk*_*hne 4 c debugging visual-studio-2008 visual-studio

我有c代码.

FILE * fin = fopen("myfile", "rb");
if (fin == NULL)
{
    printf("file myfile does not exist, closing");
    return false;
}
Run Code Online (Sandbox Code Playgroud)

它在编译时有效,但在调试模式(步进低谷)中则返回false.检查argv [0]是好的,绝对路径是双向的.

Mar*_*wis 11

在调试器中运行程序时,需要在项目调试设置中设置当前工作目录.

  • 对于需要此功能的人,在VS2017中,可以在“项目-> [ProjectName]属性->配置属性->调试->工作目录”中找到该设置。该配置保存在[ProjectName] .vcxproj.user中 (2认同)