Unix to Windows Porting Dictionary for HPC

RSS

Links

Function List

chdir


Unix

header file: unistd.h

int chdir(const char *path);

Windows

int _chdir(const char *path);

Purpose

This function changes the current working directory to the one specified in the path argument.

Discussion

Since this function has a one-to-one correspondence with the _chdir function in Windows, there should not be any other changes required other than renaming the function and including the header file.

Example of Use in Windows

#include <direct.h>

int error;
error = chdir("/tmp"));
if (!error)
  printf("Current working directory is now /tmp");
else
  printf("_chdir failed with error number %d", error);
  
blog comments powered by Disqus
Valid HTML 4.01 Transitional Valid CSS!