mac環境c++輸出工作路徑
阿新 • • 發佈:2018-12-11
windows環境中用的標頭檔案<windows.h>和<system.h>都不是c++中都檔案,而是windows系統中都,所以在類unix系統中當然就不能用啦~
上mac環境下都程式碼:
#include "iostream" #include <unistd.h> using namespace std; int main(int argc, char** argv) { const int MAXPATH=250; char buffer[MAXPATH]; getcwd(buffer, MAXPATH); printf("The current directory is: %s", buffer); }
---------------------------------------------------
我正在處理的程式的路徑竟然是:/Users/show_me_a_bit/Library/Developer/Xcode/DerivedData/testopenCV-ckobicrvyqfjbsbwpzlycvzpepoq/Build/Products/DebugProgram
這麼深,還是隱藏路徑(command+shift+。顯示隱藏檔案)。在操作檔案讀寫時還是帶上絕對路徑吧,預設路徑真讓人頭大。