中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-08-01 20:46
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » borland c 3.1 的读软盘的DBR的示例代码:改成读硬盘C盘就出措 查看 1,202 回复 0
楼 主 borland c 3.1 的读软盘的DBR的示例代码:改成读硬盘C盘就出措 发表于 2006-06-22 02:17 ·  中国 北京 联通
铂金会员
★★★★
C++启程者
积分 5,154
发帖 1,827
注册 2003-07-18 00:00
23年会员
UID 7105
性别 男
状态 离线
下面是 borland c 3.1 的读软盘的DBR的示例代码:
(改成读硬盘C盘就出措!不知道什么原因? C盘是FAT32格式,DOS下工作正常)

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

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

printf("Insert a diskette into drive A and press any key\n");
//getch();
sector = 0;
if (absread(0, 1, sector, &buf) != 0) 第一个 0 改成 2 后,读C盘出错!??
{
perror("Disk problem");
exit(1);
}
printf("Read OK\n");
strt = 3;
for (i=0; i<80; i++)
{
ch_out = buf;
putchar(ch_out);
}
printf("\n");
return(0);
}

[ Last edited by GOTOmsdos on 2006-6-22 at 02:19 ]
论坛跳转: