copy代码

2022-05-20 03:20:22   文档大全网     [ 字体: ] [ 阅读: ]

#文档大全网# 导语】以下是®文档大全网的小编为您整理的《copy代码》,欢迎阅读!
代码,copy
/*

Name: x_copy.c

Author: x-bit at 167168.kmip.net(纯技术论坛) Description: 文件copy命令,只能copy 一个文件。 用法:命令 源文件 目标文件 dev-cpp5 + win2k下调试通过; 转载请保留文章的完整性. Date: 08-11-2004

Copyright: x-bit(三哥) Allrights Reserved. */

#include void usage(char *msg) {

puts(msg);

puts("usage: command source target"); exit(0); }

void errMsg(char *msg) {

puts("File operation failure."); puts(msg); exit(0); }

int main(int argc, char *argv[])


{

FILE *si, *di; if(argc==1) {

usage("parameter error"); }

else if(argc==2) {

if(si=fopen(argv[1], "rb"))

usage("Unable copy to itself.\ncopy 0 file."); else

usage("can't open the file"); }

else if(argc>3) {

usage("parameter error"); }

if(!(si=fopen(argv[1], "rb"))) errMsg("can't open the file"); if(!(di=fopen(argv[2], "wb"))) errMsg("can't creat the file"); while(!feof(si))

fputc(fgetc(si), di);


fclose(si); fclose(di);

puts("copyed 1 file."); return 0; }

分类: 我为::C::


本文来源:https://www.wddqxz.cn/fbe74d0f763231126edb1135.html

相关推荐