| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 491 人关注过本帖
标题:新手请教,这程序为什么不能运行?
只看楼主 加入收藏
风雨中慢步
Rank: 2
等 级:论坛游民
帖 子:43
专家分:26
注 册:2011-11-4
结帖率:81.82%
收藏
已结贴  问题点数:20 回复次数:1 
新手请教,这程序为什么不能运行?
/*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;
}
搜索更多相关主题的帖子: head include system number head include system number 
2012-02-25 22:48
墨清扬
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:1
帖 子:294
专家分:817
注 册:2011-10-4
收藏
得分:20 
这是什么人写的……unsigned写成了using,0x写成了ox,main返回类型不是void,定义函数没有返回类型,没有声明定义又在调用之后……乱弹琴


酱油实习生
2012-02-26 00:01
快速回复:新手请教,这程序为什么不能运行?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019023 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved