Answers for "how to change directories in c"

0

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
Posted by: Guest on April-13-2021

Code answers related to "how to change directories in c"

Browse Popular Code Answers by Language