Syntax
#include <direct.h> int _chdrive(int drive);Description
To change the default drive, include <os2.h>, define INCL_DOSFILEMGR, and use DosSetDefaultDisk to pass the appropriate command to the operating system. You can also use DosQueryCurrentDisk to query the disk. For more information, refer to the Control Program Guide and Reference.
This example uses _chdrive to change the current working drive to C:.
#include <direct.h> #include <stdio.h> int main(void) { if (_chdrive(3)) printf("Cannot change current working drive to 'C' drive.\n"); else { printf("Current working drive changed to "); printf("'%c' drive.\n", ('A'+_getdrive()-1)); } return 0; /**************************************************************************** The output should be similar to : Current working drive changed to 'C' drive. ****************************************************************************/ }
Related Information