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>_chdrive() change current drive</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _chdrive()              Change Current Drive

 #include    <direct.h>

 int _chdrive(drive);
 int drive;                     Number of new drive (A = 1, B = 2...)

    The _chdrive() function changes the current drive to the drive
    specified by drive. However, this function changes the current
    drive only -- the chdir function changes the working directory.

    Returns:    0 if successful, or a nonzero value if not.

 Portability:   Not supported by the ANSI standard.

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

    This example just changes the current drive to B and back again:

          #include <stdio.h>
          #include <conio.h>
          #include <stdlib.h>

          void main()
          {
              int charac, workingdrive;
              static char path[_MAX_PATH];

              workingdrive = _getdrive();

              printf("Switching to drive B: \n");

              _chdrive(2);

              printf("Type a character to switch to original drive. \n");
              charac = getch();

              _chdrive(workingdrive);
          }

See Also: chdir()

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