/*
* copy_file.c
*
* Created on: Apr 6, 2013
* Author: jwang
*/
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
int c;
FILE *in, *out;
in = fopen("/root/workspace/Test/Debug/file.in", "r");
out = fopen("/root/workspace/Test/Debug/file.out", "w");
while ((c = fgetc(in)) != EOF) {
printf("%c", c);
fputc(c, out);
}
exit(0);
}
* copy_file.c
*
* Created on: Apr 6, 2013
* Author: jwang
*/
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
int c;
FILE *in, *out;
in = fopen("/root/workspace/Test/Debug/file.in", "r");
out = fopen("/root/workspace/Test/Debug/file.out", "w");
while ((c = fgetc(in)) != EOF) {
printf("%c", c);
fputc(c, out);
}
exit(0);
}
本文介绍了一个简单的文件复制程序,使用C语言实现。该程序通过fopen函数打开输入和输出文件,并利用fgetc和fputc函数逐字符读写,完成从一个文件到另一个文件的内容复制。
5158

被折叠的 条评论
为什么被折叠?



