> absread in c ~ Online tutorial

absread in c


 <a href="http://gan.doubleclick.net/gan_click?lid=41000000035692252&pubid=21000000000397534">Absread</a> reads absolute disk sectors

 Declaration:
   int absread(int drive, int nsects, long lsect, void *buffer);

 Remarks:


  absread uses DOS interrupt 0x25 to read specific disk sectors.

Both functions ignore the logical structure of a disk and pay no attention
to files, FATs, or directories.

If used improperly, abswrite can overwrite files, directories, and FATs.
The number of sectors to read (or write) is limited to 64K or the size of
the buffer, whichever is smaller.

 Return Value:
   On success, both return 0.
   On error, both return -1 and set errno to the value of the AX register
    returned by the system call.

 Example (absread only):

 /* absread example */

 #include <stdio.h>
 #include <conio.h>
 #include <process.h>
 #include <dos.h>

 int main(void)
 {
   int i, strt, ch_out, sector;
   char buf[512];

   printf("Insert a diskette into drive A and press any key\n");
   getch();
   sector = 0;
   if (absread(0, 1, sector, &buf) != 0)
   {
      perror("Disk problem");
      exit(1);
   }
   printf("Read OK\n");
   strt = 3;
   for (i=0; i<80; i++)
   {
      ch_out = buf[strt+i];
      putchar(ch_out);
   }
   printf("\n");
   return(0);
 }

Please Give Us Your 1 Minute In Sharing This Post!
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: BloggerYard.Com

0 comments: