0% found this document useful (0 votes)
57 views1 page

The End: CS609 Assignment 3 Solution Fall 2020 Solution Coding

The document contains code for a C program that writes data to a disk sector. It prompts the user to enter a file name, head number, sector number, and track number. It then uses BIOS interrupts to read the specified sector and write the data to the entered file. If successful, it prints a success message, otherwise it prints a read error message.

Uploaded by

Hamza Niaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views1 page

The End: CS609 Assignment 3 Solution Fall 2020 Solution Coding

The document contains code for a C program that writes data to a disk sector. It prompts the user to enter a file name, head number, sector number, and track number. It then uses BIOS interrupts to read the specified sector and write the data to the entered file. If successful, it prints a success message, otherwise it prints a read error message.

Uploaded by

Hamza Niaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

https://vustudents.ning.

com/
CS609 Assignment 3 Solution Fall 2020
Solution
Coding
#include <bios.h>
#include <dos.h>
#include <stdio.h>
FILE *fp;
unsigned char buf[512];
unsigned char st[60];
unsigned char headno[10 ];
unsigned char secno[10 ];
unsigned char unsigned char trackno[10 ] ;
void main (void)
{
int i;
for (i = 0; i < 512; i++)
buf[i] = 0;
printf("Please Enter Name ot the file);
gets(st);
fp=fopen(st,"wb");

printf("Please Enter Head Number:");


gets(headno);

printf("Please Enter Sector Number:");


gets(secno);

printf("Please Enter Track Number");


gets(trackno);

i = biosdisk(2,0x00,atoi(headno), atoi(trackno),atoi(secno),1, buf) ;


if (*(((char *)(&i))+1)== )
{
fwrite(buf,1,512,fp);
fclose(fp);

printf("Data is Written Successfully on the file");


}
else
{
printf("Cannot Read Error",i);
https://vustudents.ning.com/
}
getch();
}

The END

You might also like