1. 程式人生 > >8Linux伺服器程式設計之:chdir()函式和cd命令,getcwd()函式和pwd

8Linux伺服器程式設計之:chdir()函式和cd命令,getcwd()函式和pwd



1chdir依賴的標頭檔案

#include<unistd.h>

2函式定義

int chdir(const char *path);

int fchdir(int fd);

函式說明:

chdir的作用是改變工作目錄

4getcwd依賴的標頭檔案

#include<unistd.h>

5函式定義:

char *getcwd(char *buf, size_t size);

函式說明,通過這個函式獲得路徑

6.案例說明:

7.pathconf依賴的標頭檔案

#include<unistd.h>

函式定義:

longfpathconf(int fd, int name);

longpathconf(char *path, int name);

8案例說明

下面的案例是求檔名的最大長度

執行結果: