新手请教,这程序为什么不能运行?
/*Program to read MBR partition table*/#include <stdio.h>
/*struture to read the partition entry from partition table*/
struct partition
{
using char bootable; /*Active partition Byte*/
using char start_side; /* staring head */
using int start_sec_cyl; /*combination of staring sector and cylinder number*/
using char parttype; /*File system Indicator Byte*/
using char end_side; /*Ending head*/
using int end_sec_cy; /* combination of staring sector and cylinder number*/
using long part_beg; /*Relative sector number*/
using long plen ; /* patition length in sector*/
};
/*structure to read MBR*/
struct part
{
using char master_boot[446]; /* IPL (Initial program loader)*/
struct patition pt[4]; /* partition table*/
int lasttwo; /* Magic number */
};
struct part p;
void main()
{
clrscr();
/*Read First Sector of first hard disk*/
biosdisk (2,ox80,0,0,1,1,&p);
display(); /* Display the information of MBR partition table*/
getch();
}
/*Function to display the information of partition table of MBR*/
display()
{
using int s_sec,s_trk,e_sec,e_trk,i,t1,t2;
char type[20], boot [5];
printf ("\n\n part. Boot strating Ending Location Relative Number of ");
printf ("\n Type side Cylinder Sector side Cylinder sectors sectors\n");
for (i = 0; i < = 3; i ++)
{
if (p.pt[i].bootable == ox80)
strcpy (boot, "Yes");
else
strcpy (boot, "No");
switch (p.pt[i].parttype)
{
case ox00:
strcpy (type, "Unused"); break;
case ox1:
strcpy (type, "FAT12"); break;
case ox2:
strcpy (type, "Xenix"); break;
case ox3:
strcpy (type, "Xenix:usr"); break;
case ox4:
strcpy (type, "FAT16<32M"); break;
case ox5:
strcpy (type, "DOS-Ext."); break;
case ox6:
strcpy (type, "FAT16>32M"); break;
case ox7:
strcpy (type, "NTFS"); break;
case oxob:
strcpy (type, "FAT32"); break;
case oxoc:
strcpy (type, "FAT32-LBA"); break;
case oxod :
strcpy (type, "VFAT16"); break;
case oxoe:
strcpy (type, "VFAT16-LBA"); break;
case oxof:
strcpy (type, "VFAT EXT"); break;
case ox17:
strcpy (type, "HPFS"); break;
case ox81:
strcpy (type, "Old LINUX"); break;
case ox82:
strcpy (type, "LinuxSwap"); break;
case ox83:
strcpy (type, "Linux Native"); break;
case ox85:
strcpy (type, "Linux Ext"); break;
default:
strcpy (type, "Unkown"); break;
}
s_sec = (p.pt[i].start_sec_cyl&ox3f); /*straing sector of the patition */
t1 = (p.pt[i].start_sec_cyl&oxffoo) >> 8;
t2 = (p.pt[i].start_sec_cyl&oxooco) << 2;
s_trk = t1 | t2; /*startiing cylinder */
e_sec = (p.pt[i].end_sec_cyl&ox3f); /*ending sector */
t1 =(p.pt[i].end_sec_cyl&oxffoo) >> 8;
t2 = (p.pt[i].end_sec_cyl&oxooco) << 2;
e_trk = t1 | t2; /*ending cylinder */
printf ("\n%6s %3s", type, boot);
printf ("%4d %6d %8d", p.pt[i].strat_side, s_trk, s_sec);
printf ("%7d %6u %8u", p.pt[i].end_side, e_trk,e_sec);
printf (" %10lu % 10lu",p.pt[i].part_beg,p.pt[i].plen);
}
return 0;
}