【日精进】文件拷贝函数,你会写吗?
来源:互联网 发布:python源码剖析 第二版 编辑:程序博客网 时间:2024/05/17 07:18
方式:运用参数可变函数
定义两个文件指针:FILE*srcFile,FILE*destFile;
基本文件操作函数:fclose(),fopen(),fgetc(),fputc();
警告:打开一个文件时,要对结果进行判断是否打开
/*文件拷贝函数*/#include<stdio.h>int main(int argCount, char*argValue[]){ FILE*srcFile = NULL, *destFile = NULL; int ch = 0; if (argCount != 3) { printf("Usage:%s src-file-name dest-file-name\n", argValue[0]); } else { if ((srcFile = fopen(argValue[1], "r")) == 0) { printf("Can not open source file\"%s\"!", argValue[2]); } else if ((destFile = fopen(argValue[2], "W")) == 0) { printf("Can not open destination file\"%s\"!", argValue[2]); fclose(srcFile); } else { while ((ch = fgetc(srcFile)) != EOF)fputc(ch, destFile); printf("Successful to copy a file!\n"); fclose(srcFile); fclose(destFile); return 0; } } return 1;}
0 0
- 【日精进】文件拷贝函数,你会写吗?
- 拷贝文件的函数!
- C++拷贝文件函数
- 文件的拷贝函数
- 精进
- 关于文件拷贝你会了吗
- 经典的文件拷贝函数及算法
- c++实现文件拷贝,不用system函数
- NSFileManager 文件拷贝函数copyItemAtPath:toPath:error:
- C++ 文件拷贝函数 CopyFileExA 使用
- 助你在精进技术的道路上一臂之力
- EBookMgr 文件拷贝(你知道缓冲多大时拷贝文件的速度最快吗?)
- 你能够写出完整的字符串拷贝函数吗?
- 拷贝出你GAC里面的DLL文件
- 拷贝函数
- 拷贝函数
- 拷贝函数
- 拷贝函数
- java通过jni调用opencv处理图像
- 日志分割、清理维护
- Android 系列 6.31在Android中检测手势
- Android 运行时权限
- android_56_Service_音乐播放demo
- 【日精进】文件拷贝函数,你会写吗?
- VIM必看操作知识
- Some Techniques for normalizing into 0 and 1
- Android接口和框架学习
- Mac OS X下安装配置MySQL数据库
- parrot linux
- HashMap与ArrayList 的扩容问题
- each list
- win10 下编译 caffe 出现error msb4062 的解决方法