Structure and Union 411
Explanation In the above program a file name is entered whose attributes are to be displayed. The DX
register contains address of entered file. The register AL is initialized withO to get file attributes. The
register AH is always initialized with service number. Here, it is initialized with 0x43. The result
obtained is stored in the AL register. By checking the status of CL register by AND (&) operation we can
find the attributes of file. The given below Table 12.1 describes Bit status of CL and file attribute.
Table 12.3 Bit status and attributes
Bit status of CL Attribute
0
Read only file
1
Hidden file
2
System file
3 Volume label
4 Sub directory
5
Archive
6 & 7 Unused
12.35 Write a program to delete a file using dos interrupt
# include <stdio.h>
# include <conio.h>
# include <dos.h>
void sa in ()
{
union RBQS in,ou t;
ckarfilelll];
puts("n Enter a file nam e: );
scanf ("% s",file);
in,h.ah=0x41;
injc.dx=( int)file;
mtdos( &in,&out);
if(outaxflagsz^O)
puts (" n File successfully deleted");
else
puts (" n File could not be deleted");
}
OUTPUT;
Enter a file name: ABC.TXT
File successfully deleted
Explanation In the above program afile name is entered which is to be deleted. The ah register contains
service number 0x41 which performs this task. The register DX contains address of the file. If the
function is successful the flag register contains 0 otherwise non-zero value. The statuses of c flag
registers are checked using i f statement and appropriate messages are displayed.
This program works correctly only with small memory model. To delete a file the segment address
of file is stored in theDS register whereas the offset address is stored in theDX register. In this program
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.160.181