中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --
联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟
中国DOS联盟论坛
现在时间是 2026-10-31 14:55
共 47,815 主题排行 / 349,930 发帖 / 今日 0 篇 / 48,290 会员排行
DOS开发编程 & 发展交流 (开发室) » 如何用TC写一个DOS下文件拷贝的程序啊?
可打印版本  1,388 / 4
第1楼 cicada 发表于 2004-05-30 00:00
初级用户 发帖 22 积分 166
如何用TC写一个DOS下文件拷贝的程序啊?
在DOS下如何用TC写不同分区的文件拷贝的程序啊?用到哪些函数呢?帮帮忙啊!
第2楼 bush 发表于 2004-05-30 00:00
银牌会员 发帖 730 积分 2,165
要取不同分区,要用以下函数,当然写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楼 cicada 发表于 2004-05-31 00:00
初级用户 发帖 22 积分 166
"当然写copy函数可以用两个参数来完成" 哪两个参数呢?如何确定制定文件的目录呢?有没有类似的源代码啊?谢谢了!
第4楼 bush 发表于 2004-05-31 00:00
银牌会员 发帖 730 积分 2,165
刚才我写了一个,最少地调用函数,你可以参考一下:
/*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楼 cicada 发表于 2004-06-01 00:00
初级用户 发帖 22 积分 166
谢谢了。
[ 联系联盟系统管理团队 - 中国DOS联盟 - 标准版 ]
Sponsored by ifanr Inc | © 2001–2023