c change directory code example
Example: how to change directories in c
#include<stdio.h>
#include<unistd.h>
int main()
{
char cwd[256];
if (chdir("Your desired path") != 0)
perror("chdir() error()");
else {
if (getcwd(cwd, sizeof(cwd)) == NULL)
perror("getcwd() error");
else
printf("current working directory is: %s\n", cwd);
}
}
CCopy