Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Collapse the table of content
Expand the table of content


Changes the current working drive.

int _chdrive( 
   int drive 


Number of new working drive.

Return Value

_chdrive returns a value of 0 if the working drive is successfully changed. A return value of –1 indicates an error.


The _chdrive function changes the current working drive to the drive specified by drive. The drive parameter uses an integer to specify the new working drive (1=A, 2=B, and so forth). This function changes only the working drive; _chdir changes the working directory.


Routine Required header Compatibility
_chdrive <direct.h> Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.


All versions of the C run-time libraries.


See the example for _getdrive.

See Also

Directory Control Routines | _chdir | _fullpath | _getcwd | _getdrive | _mkdir | _rmdir | system | Run-Time Routines and .NET Framework Equivalents

© 2015 Microsoft