//declare
TCHAR tstrCurrentPath[MAX_PATH];
//initialize
memset(tstrCurrentPath, 0, MAX_PATH);
//Get
GetCurrentDirectory(MAX_PATH, tstrCurrentPath);
//Output
wcout << tstrCurrentPath << endl;
本文介绍了一种使用 C++ 获取程序当前工作目录的方法。通过声明并初始化字符数组,利用 `GetCurrentDirectory` 函数来填充该数组以获得当前目录的完整路径,并最终通过 `wcout` 输出到控制台。
//declare
TCHAR tstrCurrentPath[MAX_PATH];
//initialize
memset(tstrCurrentPath, 0, MAX_PATH);
//Get
GetCurrentDirectory(MAX_PATH, tstrCurrentPath);
//Output
wcout << tstrCurrentPath << endl;
被折叠的 条评论
为什么被折叠?
