C Program to Get Current Directory PWD

How to write a C Program to Get Current Directory PWD ?


Solution:

#include <unistd.h>
#include <stdio.h>

int main() {
    char cwd[1024];
    chdir("/path/to/change/directory/to");
    getcwd(cwd, sizeof(cwd));
    printf("Current working dir: %s\n", cwd);
}

C Program Quadratic equation


Learn More :