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/C++ v10.0 : C library - <b>synopsis:</b> 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 );

Description:
    The chdir function changes the current working directory to the
    specified path.  The path can be either relative to the current working
    directory or it can be an absolute path name.

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.

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


See Also:
    getcwd, mkdir, rmdir

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:
    POSIX 1003.1

Systems:
    All

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