getdisk, setdisk
raw OCR
Gets or set the current drive number.
Defined in header <dir.h>
Syntax
#include <dir.h>
int getdisk(void);
int setdisk(int drive);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ |
Remarks
getdisk gets the current drive number. It returns an integer: 0 for A, 1 for B, 2 for C, and so on (equivalent to DOS function 0x19).
setdisk sets the current drive to the one associated with drive: 0 for A, 1 for B, 2 for C, and so on (equivalent to DOS call OxOE).
Return value
getdisk returns the current drive number. setdisk returns the total number of drives available.
See also
Example
#include <stdio.h>
#include <dir.h>
int main(void)
{
int disk, maxdrives = setdisk(2);
disk = getdisk 0 + 'A' ;
printf("\nThe number of logical drives is:%d\n", maxdrives);
printfC'The current drive is: %c\n", disk) ;
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/dir.h/getdisk/
· short form /3.1/getdisk/