Получение рабочего каталога

Файлы / Базовые операции

#include <unistd.h>

//getcwd is POSIX (on Windows _getcwd from direct.h)
char workPath[FILENAME_MAX];
if (getcwd(workPath, sizeof workPath) == nullptr) {
    perror("getcwd");
    exit(EXIT_FAILURE);
}
//workPath is "/tmp/work" in the sandbox,
//on your machine the folder the program started from

//relative paths like "file.txt" start from this folder;
//chdir changes it for the whole program

printf("workPath is %s\n", workPath);