范例:
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<unistd.h>
main()
{
int fd;
fd = open(“/tmp”,O_RDONLY);
fchdir(fd);
printf(“current working directory : %s \n”,getcwd
(NULL,NULL));
close(fd);
}
执行 current working directory : /tmp |