In C CLI tools and daemon processes, obtaining the absolute filesystem path of the current working directory requires the POSIX getcwd() system function declared in <unistd.h>.

getcwd() C Code Implementation

get_cwd.cc
#include <stdio.h>
#include <unistd.h>
#include <limits.h>
 
int main(void) {
    char cwd[PATH_MAX];
 
    // Read current working directory into buffer
    if (getcwd(cwd, sizeof(cwd)) != NULL) {
        printf("Current Working Directory: %s\n", cwd);
    } else {
        perror("getcwd() error");
        return 1;
    }
 
    return 0;
}