C语言编程序,实现文本文件的复制

问题描述

C语言编程序,实现文本文件的复制
将source.txt文件复制到target.txt文件中。文件内容如下:
When you are old and grey and full of sleep, 当你老了,头发花白,睡意沉沉,
And nodding by the fire,take down this book, 倦坐在炉边,取下这本书来,
And slowly read,and dream of the soft look 慢慢读着,追梦当年的眼神
Your eyes had once,and of their shadows deep; 你那柔美的神采与深幽的晕影。
How many loved your moments of glad grace, 多少人爱过你昙花一现的身影,
And loved your beauty with love false or true, 爱过你的美貌,以虚伪或真情,
But one man loved the pilgrim Soul in you 惟独一人曾爱你那朝圣者的心,
And loved the sorrows of your changing face; 爱你哀戚的脸上岁月的留痕。
And bending down beside the glowing bars, 在炉罩边低眉弯腰,
Murmur,a little sadly,how Love fled 忧戚沉思,喃喃而语,
And paced upon the mountains overhead 爱情是怎样逝去,又怎样步上群山,
And hid his face amid a crowd of stars. 怎样在繁星之间藏住了脸。

程序代码

#include <stdio.h>
#include <stdlib.h>
/*
*csdn学院--2016级
*目的:让代码见证成长(作为一个初学的菜鸟,如
*大家有发现错误,欢迎指正!)
*文件名称:MyProject.c
*问题描述:将source.txt文件复制到target.txt文件中。
*作者:小臣小仁
*完成日期:2020年1月5日
*/
int main()
{
    FILE *fpin,*fpout;
    char c;
    if((fpin=fopen("source.txt","r"))==NULL)
    {
        printf("Soure file cannot open!");
        exit(0);
    }
    if((fpout=fopen("target.txt","w"))==NULL)
    {
        printf("Sourt file cannot open!");
        exit(0);
    }
    while((c=fgetc(fpin))!=EOF)
        fputc(c,fpout);
    printf("Finish copy!\n");
    fclose(fpin);
    fclose(fpout);
    return 0;
}

**

输出结果

soure.txt文件内容:
在这里插入图片描述
从target.tex文件复制内容:
在这里插入图片描述

心得体会

作为一个菜鸟,开始慢慢前进,多多少少感到有收获,由于水平有限,多多少少有错,望包涵

  • 11
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值