创建目录
更改当前工作目录
获取当前工作目录
#include <sys/wait.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <sys/times.h>
#include <sys/stat.h>
/**
* https://man7.org/linux/man-pages/man2/mkdir.2.html
*
*/
int main() {
const char *a = "dir01";
mkdir(a, S_IRWXU | S_IRWXG | S_IRWXO);
int ret = chdir(a);
if (ret != 0) {
printf("chdir error \n");
perror("chdir error");
exit(EXIT_FAILURE);
}
char *p = getcwd(NULL, 0);
printf("%s\n", p);
return EXIT_SUCCESS;
}
参考: https://man7.org/linux/man-pages/man2/mkdir.2.html