0
votes

When I press the Debug button in Visual Studio 2010 Express. And build this code

int main(int argc, char *argv[])
{
FILE * wFile;
float  wbuffer[] = { 1 , 2 , 3, 4};
wFile = fopen ( "myfile.bin" , "wb" );
fwrite (wbuffer , 1 , sizeof(wbuffer) , wFile );
fclose (wFile); 

/*BREAK POINT HERE*/
return 0;
}

Where does the myfile.bin go. I know where it goes when I run the program by double clicking on it. But if I'm debugging the file doesn't appear in the projectName/debug directory.

Edit: Apparently this program will find the location. But it usually the same directory as your source files.

#include <stdio.h> 
#include <direct.h>
#define GetCurrentDir _getcwd

int main(int argc, char *argv[])
{
char cCurrentPath[FILENAME_MAX];

if (!GetCurrentDir(cCurrentPath, sizeof(cCurrentPath) / sizeof(TCHAR)))
 {
 return errno;
 }

cCurrentPath[sizeof(cCurrentPath) - 1] = '\0'; /* not really required */

printf ("The current working directory is %s", cCurrentPath);


}
1

1 Answers

1
votes

It goes into what you have set as the working directory. If you right click the Project in the solution explorer and choose "Properties" -> "Configuration Properties" -> "Debugging" it will have a "Working Directory" input. It defaults to $(ProjectDir) which is the root folder for the project (you can open it from inside Visual Studio by right clicking on the project and choosing "Open Folder in Windows Explorer").