Standards / Extensions | C or C++ | Dependencies |
---|---|---|
POSIX.1 |
both |
#define _POSIX_SOURCE
#include <unistd.h>
int chdir(const char *pathname);
Makes pathname your new working directory.
If successful, chdir() changes the working directory and returns 0.
⁄* CELEBC10 *⁄
#define _POSIX_SOURCE
#include <unistd.h>
#undef _POSIX_SOURCE
#include <stdio.h>
main() {
if (chdir("⁄tmp") != 0)
perror("chdir() to ⁄tmp failed");
if (chdir("⁄chdir⁄error") != 0)
perror("chdir() to ⁄chdir⁄error failed");
}
chdir() to /chdir/error failed: No such file or directory