Skip to content

Instantly share code, notes, and snippets.

@amalaugustinejose
Created January 26, 2017 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amalaugustinejose/4def05ffb82442dd6efad0adf4470859 to your computer and use it in GitHub Desktop.
Save amalaugustinejose/4def05ffb82442dd6efad0adf4470859 to your computer and use it in GitHub Desktop.
C program create and remove a directory.
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<dos.h>
void main() {
int opr, gate = 1;
union REGS inreg, outreg;
char dname[20];
clrscr();
do {
printf("\nDirectory Operation\n\nSelect Operation\n");
printf("\t1 - Create Directory\n\t2 - Delete Directory\n");
scanf("%i", &opr);
switch (opr) {
case 1:
printf("\n\tCreate Directory\n");
printf("\nEnter name of directory : ");
scanf("%s", dname);
inreg.h.ah = 0x39;
inreg.x.dx = (unsigned)dname;
int86(0x21, &inreg, &outreg);
if(outreg.x.cflag == 0) {
printf("\nDirectory Created\n");
}
else {
printf("\nFailed to create directory\n");
}
break;
case 2:
printf("\n\tRemove Directory\n");
printf("\nEnter name of directory : ");
scanf("%s", dname);
inreg.h.ah = 0x3A;
inreg.x.dx = (unsigned)dname;
int86(0x21, &inreg, &outreg);
if (outreg.x.cflag == 0) {
printf("\nDirectory Removed\n");
}
else {
printf("\nFailed to remove directory\n");
}
break;
default :
printf("\nInvalid Operation\n");
}
printf("\nDo you want to continue : 1 or 0 : ");
scanf("%i". &gate);
}while(gate);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment