Pages

Sunday, September 4, 2011

Finding Maximum Logical Drives with C and C++

This article will show how to know the current drive’s name and the maximum logical drives that your system supports with C and C++. The getdisk () function is used to show the current drive name and the setdisk () function is used to know the maximum logical drives of any system. The programming code to find Maximum Logical Drives with C and C++ is given below.


#include<stdio.h>
#include<conio.h>
#include<dir.h>

void main()
{
  clrscr();
  int disk, maxdrive;
  disk=getdisk()+'A';
  maxdrive=setdisk(2);
  printf("Current drive is : %c\n",disk);
  printf("Maximum logical drive is:%d\n",maxdrive);
  getch();
}

Output