C++获取当前目录

时间:2023-03-09 08:32:40
C++获取当前目录
 /*
@author:CodingMengmeng
@theme:C++获取当前目录
@time:2017-1-6 21:03:34
@blog:http://www.cnblogs.com/codingmengmeng/
*/
#include <iostream>
#include <direct.h>
using namespace std;
/***********************************************************************
*函数名称: _getcwd
*函数原型: char * _cdecl _getcwd(char *_DstBuf,int _SizeInBytes)
*函数功能: 得到当前路径名称
*函数返回: 指向dir的指针
*参数说明: _DstBuf-路径字符串;_SizeInBytes-路径最大长度
*头 文 件: <direct.h>
*vs的版本: VS2013
*************************************************************************/
int main(void)
{
char buff[];
_getcwd(buff, );
cout << "当前路径是:" << buff << endl;
getchar();
return ;
}

运行结果:

C++获取当前目录