- #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
-
- #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
时间: 2024-10-13 20:40:39