您的位置:首页 > 编程语言 > C语言/C++

C++获取当前目录

2017-01-06 21:05 225 查看
/*
@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[1000];
_getcwd(buff, 1000);
cout << "当前路径是:" << buff << endl;
getchar();
return 0;
}


运行结果:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: