获取程序当前工作目录
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char const *argv[])
{
char buf[1024] = {0};
getcwd(buf, sizeof(buf));
printf("%s\n", buf);
return 0;
}
假设程序当前所在目录为/home/zss/temp-folder/ccc,打印的buf就是/home/zss/temp-folder/ccc