c语言文件读写的一个例子
2013-03-19 23:26
344 查看
看代码:
perror函数主要是为了便于调试,fflush是清楚缓存,fclose是文件打开后要关闭。
#include <stdio.h> #include<stdlib.h> #include<time.h> int main() { FILE *input ,*destfile; int t; input = fopen("D:/1.txt","r"); destfile = fopen("D:/2.txt" , "w"); if(input == NULL) { perror("the file is empity"); exit(EXIT_FAILURE); } else { perror("the file is not empity"); while(!feof(input)) { t = fgetc(input); if(t =='{') { t ='s'; } printf("%c" , t); fputc(t , destfile); } } fflush(stdout); fclose(destfile); fclose(input); return 0; }把1.txt文件中的内容放到2.txt文件。这里有个问题,那就是2.txt文件最后有个类似y上面有两点的字符不知道是什么。
perror函数主要是为了便于调试,fflush是清楚缓存,fclose是文件打开后要关闭。
相关文章推荐
- 【转载】关于:读写xls文件,提供下载的一个小例子(jxl 的简单运用) - 读取文件
- 【转载】关于:读写xls文件,提供下载的一个小例子(jxl 的简单运用) - 高级操作
- C语言文件的读写操作,每次读取1K,然后写入另外一个文件
- bcb 读写ini 配置文件的一个例子
- 关于:读写xls文件,提供下载的一个小例子(jxl 的简单运用) - 创建文件
- 关于:读写xls文件,提供下载的一个小例子(jxl 的简单运用) - 读取文件
- 一个文件读写的简易例子
- 关于:读写xls文件,提供下载的一个小例子(jxl 的简单运用) - 高级操作
- MSDN看到的一个读写文件及路径等操作的例子,觉得可以学习一下。。。
- 一个文件读写的简易例子
- java:IO-一个文件读写例子
- 一个简单的文件读写、复制的例子
- 通过一个文件拷贝的例子了解二进制文件的读写
- 一个读写ini文件属性的例子
- Android读写文件的一个简单入门的例子
- 关于:读写xls文件,提供下载的一个小例子(jxl 的简单运用)
- C# 类用XmlSerializer进行序列化和反序列化进行文件读写的一个简单例子
- C# ArrayList用BinaryFormatter序列化和反序列化进行文件读写的一个简单例子
- 文件读写的一个例子
- 【转载】关于:读写xls文件,提供下载的一个小例子(jxl 的简单运用) - 创建文件