- 主题
- 68
- 帖子
- 348
- 精华
- 0
- 积分
- 635
- C币
- 578 枚
- 在线时间
- 57 小时
- 注册时间
- 2010-7-9
- 最后登录
- 2012-1-28
- 性别
- 保密
 
- 主题
- 68
- 帖子
- 348
- C币
- 578 枚
- 在线时间
- 57 小时
|
发表于 2010-8-20 09:20:17
|显示全部楼层
- #include <stdio.h>
- #include <stdlib.h>
- #define READ_LENGTH 20
- int main(int argc, char *argv[])
- {
- FILE *fp;
- FILE *addfp;
- char *source;
- char *target;
- char s[READ_LENGTH];
- if(1==argc||2==argc)
- {
- printf("Please input the target file's name:\n");
- exit(0);
- }
- source=argv[1];
- target=argv[2];
- if(NULL==(fp=fopen(source,"r")))
- {
- printf("can not open the source file!\n");
- exit(0);
- }
- if(NULL==(addfp=fopen(target,"a+")))
- {
- printf("can not open the target file!\n");
- exit(0);
- }
- while(!feof(fp))
- {
- fread(s,sizeof(char),READ_LENGTH,fp);
- fwrite(s,sizeof(char),READ_LENGTH,addfp);
- }
- fclose(fp);
- fclose(addfp);
- return 1;
- }
复制代码 |
|