本文共 301 字,大约阅读时间需要 1 分钟。
相关函数:getcwd, chroot 头文件:#include <unistd.h> 定义函数:int chdir(const char * path); 函数说明:chdir()用来将当前的工作目录改变成以参数path 所指的目录. 返回值执:行成功则返回0, 失败返回-1, errno 为错误代码. 范例 #include <unistd.h> main() { chdir("/tmp"); printf("current working directory: %s\n", getcwd(NULL, NULL)); } 执行: current working directory :/tmp 转载地址:http://zzexi.baihongyu.com/