1.文件IO----COPY的实现
来源:互联网 发布:arcgis如何生成元数据 编辑:程序博客网 时间:2024/05/29 17:07
《Makefile》
***************
CC=gcc
TEXT=copy
SVC=file_copy.c debug.h
$(TEXT): $(SVC)
$(CC) -o $@ $^
clean:
rm -rf $(TEXT) *.o
******************************
《头文件》
/*Comment/uncomment the following line to disable/enable debugging,
OR define(or NOT) it in Makefile.
*/
//#define NDEBUG
#undef pr_debug /* undef it, just in case */
#ifndef NDEBUG
#ifdef __KERNEL__
/* This one if debugging is on, and kernel space */
#define pr_debug(fmt, args...) printk( KERN_ERR fmt, ## args)
#else
/* This one for user space */
#define pr_debug(fmt, args...) fprintf(stderr, fmt, ## args)
#endif
#else
#define pr_debug(fmt, args...) /* not debugging: nothing */
#endif
******************************
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include "debug.h"
/*usage: ./file_copy file1 file2 */
void usage (const char *s)
{
printf("usage:\n\t%s src_file dest_file\n", s);
}
int main(int argc, char **argv)
{
FILE * src_fp, *dst_fp;
if (argc != 3) {
usage(argv[0]);
exit(1);
}
src_fp = fopen(argv[1], "r");
dst_fp = fopen(argv[2], "w+");
assert( (src_fp !=NULL) && (dst_fp != NULL) );
if (!src_fp || !dst_fp ) {
usage(argv[0]);
exit(1);
}
pr_debug("Hello, copying start!\n");
while( !feof(src_fp)) {
int c,d;
c = fgetc(src_fp);
d = fputc(c, dst_fp);
if (d == EOF) {
pr_debug("fputc");
continue;
}
}
pr_debug("OK, copying finished!\n");
fclose(src_fp);
fclose(dst_fp);
return 0;
}
- 1.文件IO----COPY的实现
- IO实现文件COPY
- IO流的文件copy和目录copy
- IO字符流的copy文件方法!
- Lua IO文件copy
- 【java io】io copy文件
- 在 java控制台实现 类似java Copy srcpath despath这种DOS命令行的文件拷贝功能 文件IO StringBuffer
- IO操作的一个例子(copy文件的命令)
- java文件copy操作,IO,
- Java IO进行文件copy
- 利用io流copy文件
- java关于(io&nio) 的 文件copy例子
- Java io copy 复制文件的几种场景
- Java中高级IO流的使用-Copy文件
- 【IO流】FileReader,FileWriter完成文件的copy
- 【转】实现copy文件功能的代码
- fgetc,fgets实现文件的copy
- fread/fwrite实现文件的copy
- 代码片断3
- 开发经验总结,很受用。(一般般,不过还是感谢作者)
- C#判断某个文件是否存在
- 从Java类库看设计模式
- ubuntu 如何安装 VMware Tools
- 1.文件IO----COPY的实现
- linux2.6驱动编程第一例:hello,world的实现
- ubuntu 11.10 配置 tftp服务器
- .NET的3C:CTS、CLS和CLR
- 17种正则表达式
- 获取运行文件路径
- oracle job介绍
- c# 控件随窗体大小改变
- 经典的编程引言