2012-01-27 29 views
0

当我按在Visual Studio 2010 Express中的Debug按钮。并建立此代码是否调试在另一个文件夹中的Visual Studio的地方建文件

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; 
} 

myfile.bin在哪里去。当我通过双击运行程序时,我知道它会发生什么。但是如果我正在调试该文件没有出现在projectName/debug目录中。

编辑:显然,这个程序会找到位置。但它通常与源文件的目录相同。

#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

它进入你设定的工作目录。如果您在解决方案资源管理器中右键单击项目并选择“属性” - >“配置属性” - >“调试”,它将会有一个“工作目录”输入。它默认为$(ProjectDir),它是项目的根文件夹(您可以通过右键单击项目并选择“在Windows资源管理器中打开文件夹”从Visual Studio中打开它)。

+0

我希望VS快讯2010年有此配置选项,在几年前的VS Express时有所削弱,而错过了许多配置选项......我快要疯了,因为我没能释放/调试之间切换: - ) – Max 2012-01-27 20:45:21

相关问题