Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio debugging execution path

I have c code like.

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

It works when compiled, but not in debugging mode (stepping trough) where it return false. checking argv[0] is ok and absolute paths are working both ways.

like image 402
Luka Rahne Avatar asked Dec 13 '22 03:12

Luka Rahne


1 Answers

When you run the program in the debugger, you need to set the current working directory, in the project debug settings.

As pointed below by user Irhala A in Visual Studio 2017 the setting is found at "Project -> [ProjectName] Properties -> Configuration Properties -> Debugging -> Working Directory".

like image 133
Martin v. Löwis Avatar answered Dec 22 '22 05:12

Martin v. Löwis