This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/clibexam/setdrive.c

20 lines
550 B
C
Raw Permalink Normal View History

#include <stdio.h>
#include <dos.h>
void main()
{
unsigned drive1, drive2, total;
_dos_getdrive( &drive1 );
printf( "Current drive is %c\n", 'A' + drive1 - 1 );
/* try to change to drive C */
_dos_setdrive( 3, &total );
_dos_getdrive( &drive2 );
printf( "Current drive is %c\n", 'A' + drive2 - 1 );
/* go back to original drive */
_dos_setdrive( drive1, &total );
_dos_getdrive( &drive1 );
printf( "Current drive is %c\n", 'A' + drive1 - 1 );
printf( "Total number of drives is %u\n", total );
}