您的位置:首页 > 运维架构

库函数fopen/fgetc/fputc实现两个文件内容的复制

2017-03-06 15:56 253 查看
/*****************************************************
copyright (C), 2014-2015, Lighting Studio. Co.,     Ltd.
File name:
Author:Jerey_Jobs    Version:0.1    Date:
Description:
Funcion List:
*****************************************************/

#include <stdio.h>
#include <stdlib.h>
#include<string.h>

int main()
{
FILE *from_file,*to_file;
char ch;

if((from_file = fopen("a.txt","r+")) == NULL)
{
printf("from_file open fali!\n");
exit(1);
}
if((to_file = fopen("b.txt","w+")) == NULL)
{
printf("to_file open fali!\n");
exit(1);
}

while(fgetc(ch,from_file) != EOF)
{
fputc(ch,to_file);
}

fclose(from_file);
fclose(to_file);
printf("\n");
return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c语言 linux 函数