#include<fstream.h>
#include<conio.h>
void main()
{
int iSize,iChoice,iDelete,iMem={1024};
clrscr();
cout << "Brand New Flash Drive\n";
cout << "Message: Free Space: " << iMem << "";
getch();
clrscr();
while(iChoice!=8)
{
cout << "\n";
cout << "[1] Format Flash Drive\n";
cout << "[2] Copy File\n";
cout << "[3] Delete File\n";
cout << "[4] Available Space\n";
cout << "[5] Used Space\n";
cout << "[6] Lock Flash Drive\n";
cout << "[7] Unlock Flash Drive\n";
cout << "[8] Exit\n";
cout << "\n";
cout << "Enter Choice: ";
cin >> iChoice;
switch(iChoice){
case 1: cout << "Message: Format successful...";
iMem=1024;
iSize=0;
if(iMem==Lock)
cout << "Message: Can't Format. Flash drive is locked...";
getch();
clrscr();
break;
case 2: cout << "Message: Enter Size: ";
cin >> iSize;
if((iSize>iMem)&&(iSize>1024))
cout << "Unsuccessful. Flash drive locked or file too large.";
else if(iSize==Lock)
cout << "Message: Can't Format. Flash drive is locked...";
else
iMem=iMem-iSize;
cout << "File copied";
getch();
clrscr();
break;
case 3: cout << "Message: Enter Size: ";
cin >> iDelete;
if(iDelete>iSize)
cout << "Unsuccessful. Flash drive locked or file too large.";
else if(iDelete==Lock)
cout << "Message: Can't Format. Flash drive is locked...";
else
iMem=iMem+iSize;
iSize=0;
cout << "File deleted";
getch();
clrscr();
break;
case 4: cout << "Message: Free space: " << iMem << "";
getch();
clrscr();
break;
case 5: cout << "Message: Used space: " << iSize << "";
getch();
clrscr();
break;
case 6: cout << "Message: Flash drive locked...";
Format Disk==Unlock;
iSize==Lock;
iDelete==Lock;
getch();
clrscr();
break;
case 7: cout << "Message: Flash drive unlocked...";
Format Disk==Lock;
iDelete==Unlock;
iSize==Unlock;
getch();
clrscr();
break;
case 8: cout << "Message: Press any key to exit...";
getch();
clrscr();
break;
default: cout << "Invalid Input";
getch();
clrscr();
break;
}
}
getch();
}
I need to know how to lock Format Flash Drive, Copy File, Delete File when i choose the case 6 or the Lock Flash Drive.I need to know also how to unlock it when i choose the case 7 or the Unlock Flash Drive. I need to know also how to save the variable. Like when i choose the copy file and i inserted 300 and the remaining free space is 724 and the used space is 300 and i exit the program when i opened it again i will see the 724 free space and 300 used space. Edit my program if you like. Thanks