版權所有 © 2014 tutorialspoint
/* * This page documents the getcwd(2) system call, which * is not defined in any user-space header files; you should * use getcwd(3) defined in <unistd.h> instead in applications. */ long getcwd(char *buf, unsigned long size);
long getcwd(char *buf, unsigned long size);
如果當前絕對路徑名所需的緩衝區長度超過 size 個元素,則返回 -1,並將 errno 設定為 ERANGE;應用程式應檢查此錯誤,並在必要時分配更大的緩衝區。
如果 buf 為 NULL,則 getcwd() 的行為未定義。
請注意,此返回值與 getcwd(3) 庫函式不同,後者在失敗時返回 NULL,在成功時返回 buf 的地址。
廣告