randbrd

编辑:离愁网互动百科 时间:2019-11-15 06:49:48
编辑 锁定
本词条缺少概述名片图,补充相关内容使词条更完整,还能快速升级,赶紧来编辑吧!
中文名
randbrd
函数名
randbrd
功 能
随机块读
用 法
 int randbrd

目录

randbrd简介

编辑
函数名: randbrd
功 能: 随机块读
用 法: int randbrd(struct fcb *fcbptr, int reccnt);

randbrd程序例:

编辑
#include
#include
#include
#include
int main(void)
{
char far *save_dta;
char line[80], buffer[256];
struct fcb blk;
int i, result;
/* get user input file name for dta */
printf("Enter drive and file name (no path - i.e. a:file.dat)\n");
gets(line);
/* put file name in fcb */
if (!parsfnm(line, &blk, 1))
{
printf("Error in call to parsfnm\n");
exit(1);
}
printf("Drive #%d File: %s\n\n", blk.fcb_drive, blk.fcb_name);
/* open file with DOS FCB open file */
bdosptr(0x0F, &blk, 0);
/* save old dta, and set new one */
save_dta = getdta();
setdta(buffer);
/* set up info for the new dta */
blk.fcb_recsize = 128;
blk.fcb_random = 0L;
result = randbrd(&blk, 1);
/* check results from randbrd */
if (!result)
printf("Read OK\n\n");
else
{
perror("Error during read");
exit(1);
}
/* read in data from the new dta */
printf("The first 128 characters are:\n");
for (i=0; i<128; i++)
putchar(buffer);
/* restore previous dta */
setdta(save_dta);
return 0;
}
词条标签:
计算机学