C++获取当前目录

/*
@author:阿玛尼迪迪
@转载:https://www.cnblogs.com/codingmengmeng/p/6257722.html
*/
#include <iostream>
#include <direct.h>
using namespace std;
/***********************************************************************
*函数名称:     _getcwd
*函数原型:     char * _cdecl _getcwd(char *_DstBuf,int _SizeInBytes)
*函数功能:     得到当前路径名称
*函数返回:     指向dir的指针
*参数说明:     _DstBuf-路径字符串;_SizeInBytes-路径最大长度
*头 文 件:     <direct.h>
*************************************************************************/
int main(void)
{
    char buff[1000];
    _getcwd(buff, 1000);
    cout << "当前路径是:" << buff << endl;
    getchar();
    return 0;
}

原文地址:https://www.cnblogs.com/hsy1941/p/14023103.html