_getdrive

From RAD Studio
Jump to: navigation, search

Go Up to dos.h Index

Header File

dos.h

Category

Directory Control Routines

Prototype

int _getdrive(void);

Description

Gets the current drive.

_getdrive gets the the current drive number. It returns an integer: 1 for A, 2 for B, 3 for C, and so on.

Return Value

_getdrive returns the current drive number on success or -1 in the event of error.

Example

#include <stdio.h>
#include <direct.h>
int main(void)
{
  int disk;
  disk = _getdrive() + 'A' - 1;
  printf("The current drive is: %c\n", disk);
  return 0;
}