中国DOS联盟

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

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

中国DOS联盟论坛
现在时间是 2026-08-01 08:00
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » 如何用TC写一个DOS下文件拷贝的程序啊? 查看 1,214 回复 4
楼 主 如何用TC写一个DOS下文件拷贝的程序啊? 发表于 2004-05-30 00:00 ·  中国 河南 郑州 教育网
初级用户
积分 166
发帖 22
注册 2004-05-30 00:00
22年会员
UID 25662
性别 男
状态 离线
在DOS下如何用TC写不同分区的文件拷贝的程序啊?用到哪些函数呢?帮帮忙啊!
2 发表于 2004-05-30 00:00 ·  中国 重庆 渝中区 电信
银牌会员
★★★
积分 2,165
发帖 730
注册 2004-04-21 00:00
22年会员
UID 22966
性别 男
状态 离线
要取不同分区,要用以下函数,当然写copy函数可以用两个参数来完成,应该不难。
getdisk: gets current drive

int getdisk(void);

Prototype in dir.h

Returns the current drive. Drive A is 0.

setdisk: sets current disk drive

int setdisk(int drive);

Prototype in dir.h

Values for drive are 0=A, 1=B, 2=C etc.

Returns the total number of drives available.

3 发表于 2004-05-31 00:00 ·  中国 河南 郑州 教育网
初级用户
积分 166
发帖 22
注册 2004-05-30 00:00
22年会员
UID 25662
性别 男
状态 离线
"当然写copy函数可以用两个参数来完成" 哪两个参数呢?如何确定制定文件的目录呢?有没有类似的源代码啊?谢谢了!
4 发表于 2004-05-31 00:00 ·  中国 重庆 渝中区 电信
银牌会员
★★★
积分 2,165
发帖 730
注册 2004-04-21 00:00
22年会员
UID 22966
性别 男
状态 离线
刚才我写了一个,最少地调用函数,你可以参考一下:
/*filename: mycopy.c a example for copy a file to another file*/
#include
int main(int argc,char* argv)
{
FILE *fpo,*fpi;
int tmp;
char *fname;
if(argc==1)
{
printf("Syntax is mycopy sourcefile targetfile\n";
exit (1);
}
fpi=fopen(argv,"rb";
if(!fpi)
{
printf("cannot open the sourcefile!\n";
exit (2);
}
if(argc==2)
{
printf("Please input target file name:";
while(scanf("%s",&fname));
fpo=fopen(fname,"wb";
}
else fpo=fopen(argv,"wb";
if(!fpo)
{
printf("cannot creat the targetfile!\n";
exit (3);
}
while((tmp=fgetc(fpi))!=EOF)
fputc(tmp,fpo);
fclose(fpi);
fclose(fpo);
return 0;
}

5 发表于 2004-06-01 00:00 ·  中国 河南 郑州 教育网
初级用户
积分 166
发帖 22
注册 2004-05-30 00:00
22年会员
UID 25662
性别 男
状态 离线
谢谢了。
论坛跳转: