Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>chdir() change current working directory</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 chdir()                 Change Current Working Directory

 #include   <direct.h>                   Required for declarations only

 int        chdir(pathname);
 char       *pathname;                   Path Name of new working directory

    chdir() changes the current working directory to 'pathname', which
    must refer to an existing directory.


    Returns:    Zero if the directory is successfully changed; or -1, if
                the specified path could not be found, in which case
                'errno' is set to ENOENT (path could not be found).

      Notes:    Use two backslashes ("\\") to represent a single
                backslash in strings, since the backslash is an escape
                character in C.

                chdir() can change the current working directory on any
                drive, but it cannot change the drive itself. For
                example, if the current default drive is A:, the current
                default directory on C: can be changed by the following
                call:

                chdir( "c:\\newdir" );

                Although the call will have no apparent immediate effect,
                when the OS/2 function DOSSELECTDISK is called to change
                the default drive to C:, the current working directory
                becomes C:\NEWDIR.

                In OS/2 protected mode the current working directory is
                local to a process rather than system-wide.

 Portability:   Xenix, MS-DOS, and OS/2. In MS-DOS and OS/2, only the
                ENOENT value will be returned for errno.


   -------------------------------- Example ---------------------------------

    The following statement changes the current working directory to
    '\TEST':

           #include <direct.h>

           main()
           {
               chdir("\\TEST");
           }



See Also: _chdrive() mkdir() rmdir() system()

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