Windows下,
获得工作目录如下:
#include <direct.h>#include <stdio.h> char buffer[MAX_PATH]; getcwd(buffer, MAX_PATH); printf( "The current directory is: %s ", buffer); //打印出E:/C++/cppTest/cppPrimerTest
获得exe当前目录:
#include <windows.h> char chpath[MAX_PATH]; GetModuleFileName(NULL,(LPSTR)chpath,sizeof(chpath)); std::cout<<chpath<<std::endl;//打印出:E:/C++/cppTest/cppPrimerTest/Debug/cppTest.exe
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow