int main(void)
{
int i, strt, ch_out, sector;
char buf[512]; /* 将要写的放入buf */
printf("Insert a diskette into drive A and press any key\n");
getch();
sector = 0;
if (abswrite(0, 1, sector, &buf) != 0)
{
perror("Disk problem");
exit(1);
}
printf("Write OK\n");
return(0);
}
absread and abswrite absread reads absolute disk sectors
abswrite writes absolute disk sectors
(Not available under MS-Windows.)
Syntax:
int absread(int drive, int nsects, long lsect, void *buffer);
int abswrite(int drive, int nsects, long lsect, void *buffer);
Prototype in:
dos.h
■ drive is 0 = A, 1 = B, 2 = C, etc.
■ nsects is the number of sectors to read/write
■ lsect is starting logical sector (0 is first)
■ buffer is address of data area.
The number of sectors to read or write is limited to the amount of memory in
the segment above the buffer.
64K is the largest amount of memory per call that can be read in or written.
Returns 0 for success; on error, returns -1 and sets errno.