Go to the first, previous, next, last section, table of contents.


chdir

Syntax

#include <unistd.h>

int chdir(const char *new_directory);

Description

This function changes the current directory to new_directory. If a drive letter is specified, the current directory for that drive is changed and the current disk is set to that drive, else the current directory for the current drive is changed.

Return Value

Zero if the new directory exists, else nonzero and errno set if error.

Portability

not ANSI, POSIX

Example

if (chdir("/tmp"))
  perror("/tmp");


Go to the first, previous, next, last section, table of contents.