_getdrive -- Get Current Working Drive

Format

#include <direct.h>
int _getdrive(void);

Language Level: Extension
_getdrive gets the drive number for the current working drive.

An alternative to this function, on OS/2, is the DosQueryCurrentDisk API call.

For Windows, an alternative to this function is the GetCurrentDirectory API call.

Return Value
_getdrive returns an integer corresponding to alphabetical position of the letter representing the current working drive. For example, A: is 1, B: is 2, J: is 10, and so on.

Example
This example gets and prints the current working drive number.

#include <stdio.h>
#include <direct.h>
int main(void)
{
   printf("Current working drive is %d.\n", _getdrive());
   return 0;
   /*****************************************************
      The output should be similar to:
      Current working drive is 5.
   *****************************************************/
}



chdir -- Change Current Working Directory
_chdrive -- Change Current Working Drive
_getcwd -- Get Path Name of Current Directory
_getdcwd -- Get Full Path Name of Current Directory
#<direct.h>