Chapter Contents |
Previous |
Next |
chdir |
Portability: | POSIX.1 conforming, UNIX compatible |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
IMPLEMENTATION | |
EXAMPLE | |
RELATED FUNCTIONS | |
SEE ALSO |
SYNOPSIS |
#include <unistd.h> int chdir(const char *pathname);
DESCRIPTION |
chdir
changes the working directory to
pathname
.
The
pathname
function must specify the
name of a file in the USS HFS. See File Naming Conventions for information on specifying USS file names.
RETURN VALUE |
chdir
returns 0 if it is successful and -1 if it is not successful.
IMPLEMENTATION |
When you call
chdir
in an application compiled without the
posix
option, the directory name will be interpreted according to the
normal rules for interpretation of filenames. The directory name should include
a style prefix if the default style is not
"hfs"
.
EXAMPLE |
/* This example must be compiled with POSIX to run successfully. */ #include <stdio.h> #include <unistd.h> char wrkdir[FILENAME_MAX]; main() { /* Change the working directory to /bin. */ if (chdir("/bin") != 0) perror("chdir() to /bin failed"); else { /* Determine the current working directory. */ if (getcwd(wrkdir,sizeof(wrkdir)) == NULL) perror("getcwd() error"); else printf("Current working directory is: %s\n",wrkdir); } }
RELATED FUNCTIONS |
SEE ALSO |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.