- #include <direct.h>
- #include <stdio.h>
- char buffer[MAX_PATH];
- getcwd(buffer, MAX_PATH);
- printf( "The current directory is: %s ", buffer);
- #include <windows.h>
- char chpath[MAX_PATH];
- GetModuleFileName(NULL,(LPSTR)chpath,sizeof(chpath));
- std::cout<<chpath<<std::endl;
c++ 获得程序所在目录
原文:http://www.cnblogs.com/aqdaye/p/5236032.html