C++ Visual Studio当前工作目录

dtm*_*and 4 c++ visual-studio-2012

我有一个类似的问题: 当前的工作目录是visual studio目录

除了我在Visual Studio中使用C++项目.有什么建议?

例如,如果我在以下帖子中尝试解决方案: GetCurrentDirectory for startup App.C++

我明白了:

"C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE"
Run Code Online (Sandbox Code Playgroud)

但我希望它是我的项目/解决方案文件夹下的Debug文件夹.

dtm*_*and 8

使用_fullpath命令允许我提取当前目录.例如,您可以修改链接页面上的示例代码:

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <direct.h>

void PrintFullPath( char * partialPath )
{
   char full[_MAX_PATH];
   if( _fullpath( full, partialPath, _MAX_PATH ) != NULL )
      printf( "Full path is: %s\n", full );
   else
      printf( "Invalid path\n" );
}

int main( void )
{
   // Get current directory
   PrintFullPath( ".\\" );
}
Run Code Online (Sandbox Code Playgroud)