问题描述
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学院--级*目的:让代码见证成长(作为一个初学的菜鸟,如*大家有发现错误,欢迎指正!)*文件名称:MyProject.c*问题描述:将source.txt文件复制到target.txt文件中。*作者:小臣小仁*完成日期: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文件复制内容:
心得体会
作为一个菜鸟,开始慢慢前进,多多少少感到有收获,由于水平有限,多多少少有错,望包涵
如果觉得《C语言编程序 实现文本文件的复制》对你有帮助,请点赞、收藏,并留下你的观点哦!