Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <sys\types.h>
    #include <direct.h>
    int chdir( const char *path );
    int _wchdir( const wchar_t *path );

Description:
    The chdir function changes the current directory on the specified drive
    to the specified path.  If no drive is specified in path then the
    current drive is assumed.  The path can be either relative to the
    current directory on the specified drive or it can be an absolute path
    name.

    Each drive under DOS, OS/2 or Windows NT has a current directory.  The
    current working directory is the current directory of the current drive.
     If you wish to change the current drive, you must use the
     _dos_setdrive function.

    The _wchdir function is identical to chdir except that it accepts a
    wide-character string argument.

Returns:
    The chdir function returns zero if successful.  Otherwise, -1 is
    returned,  errno is set to indicate the error, and the current working
    directory remains unchanged.

Errors:
    When an error has occurred,  errno contains a value indicating the type
    of error that has been detected.

    Constant     Meaning

ENOENT
    The specified path does not exist or path is an empty string.


Example:
    #include <stdio.h>
    #include <stdlib.h>
    #include <direct.h>

    void main( int argc, char *argv[] )
      {
        if( argc != 2 ) {
          fprintf( stderr, "Use: cd <directory>\n" );
          exit( 1 );
        }

        if( chdir( argv[1] ) == 0 ) {
          printf( "Directory changed to %s\n", argv[1] );
          exit( 0 );
        } else {
          perror( argv[1] );
          exit( 1 );
        }
      }

Classification:
    chdir is POSIX 1003.1, _wchdir is not POSIX

Systems:
     chdir - All, Netware

    _wchdir - DOS, Windows, Win386, Win32, OS/2 1.x(all), OS/2-32

See Also:
    chmod, _dos_setdrive, getcwd, mkdir, rmdir, stat, umask

See Also: _dos_setdrive umask

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson