_chdir, _wchdir
Change the current working directory.
int _chdir( const char *dirname );
int _wchdir( const wchar_t *dirname );
Routine Required Header Optional Headers Compatibility
_chdir <direct.h> <errno.h> Win 95, Win NT
_wchdir <direct.h> or <wchar.h> <errno.h> Win NT
For additional compatibility information, see Compatibility in the Introduction.
Libraries
LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version
Return Value
Each of these functions returns a value of 0 if successful. A return value of –1 indicates that the specified path could not be found, in which case errno is set to ENOENT.
Parameter
dirname
Path of new working directory
Remarks
The _chdir function changes the current working directory to the directory specified by dirname. The dirname parameter must refer to an existing directory. This function can change the current working directory on any drive and if a new drive letter is specified in dirname, the default drive letter will be changed as well. For example, if A is the default drive letter and \BIN is the current working directory, the following call changes the current working directory for drive C and establishes C as the new default drive:
_chdir("c:\\temp");
When you use the optional backslash character (\) in paths, you must place two backslashes (\\) in a C string literal to represent a single backslash (\).
_wchdir is a wide-character version of _chdir; the dirname argument to _wchdir is a wide-character string. _wchdir and _chdir behave identically otherwise.
Generic-Text Routine Mapping:
TCHAR.H Routine _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined
_tchdir _chdir _chdir _wchdir
Example
/* CHGDIR.C: This program uses the _chdir function to verify
* that a given directory exists.
*/
_chdir, _wchdir
Change the current working directory.
int _chdir( const char *dirname );
int _wchdir( const wchar_t *dirname );
Routine Required Header Optional Headers Compatibility
_chdir <direct.h> <errno.h> Win 95, Win NT
_wchdir <direct.h> or <wchar.h> <errno.h> Win NT
For additional compatibility information, see Compatibility in the Introduction.
Libraries
LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version
Return Value
Each of these functions returns a value of 0 if successful. A return value of –1 indicates that the specified path could not be found, in which case errno is set to ENOENT.
Parameter
dirname
Path of new working directory
Remarks
The _chdir function changes the current working directory to the directory specified by dirname. The dirname parameter must refer to an existing directory. This function can change the current working directory on any drive and if a new drive letter is specified in dirname, the default drive letter will be changed as well. For example, if A is the default drive letter and \BIN is the current working directory, the following call changes the current working directory for drive C and establishes C as the new default drive:
_chdir("c:\\temp");
When you use the optional backslash character (\) in paths, you must place two backslashes (\\) in a C string literal to represent a single backslash (\).
_wchdir is a wide-character version of _chdir; the dirname argument to _wchdir is a wide-character string. _wchdir and _chdir behave identically otherwise.
Generic-Text Routine Mapping:
TCHAR.H Routine _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined
_tchdir _chdir _chdir _wchdir
Example
/* CHGDIR.C: This program uses the _chdir function to verify
* that a given directory exists.
*/