库函数调用 4--fwrite
2015-06-21 19:12
218 查看
#include <stdio.h> /************************ *name:fwrite.c *author:QG *time:2015-05-12 *description: ***************************/ int main() { FILE *fp_in; FILE *fp_out; char *in_file_name = "./123.txt"; char *out_file_name = "./234.txt"; int a = 1; int b = 0; int c = 0; char c_buf[10]; fp_in = fopen(in_file_name,"r+"); b = fread(c_buf,1,9,fp_in); c_buf[9] = '\0'; printf("read %d types from 123.txt!\n",b); printf("read content is :%s!\n",c_buf); fp_out = fopen(out_file_name,"w+"); c = fwrite(c_buf,1,9,fp_out); printf("write %d types to 234.txt!\n",c); a = fclose(fp_in); fclose(fp_out); if(a == 0) { printf("close OK!\n"); } else if(a == EOF) { printf("close fail!\n"); } return 0; }
相关文章推荐
- 库函数调用 5--fseek
- 博客读后感
- 计算脚本执行时间
- 库函数调用 3--fread
- hdu4612Warm up tarjan+树形dp
- 库函数调用 2--fclose
- jQuery对象和DOM对象之间的相互转换
- js实现购物车(源码)
- 微软的最高市值是多少?
- bootstrap的对话框和提示信息
- hdoj 3501 Calculation 2
- iBeacon
- 库函数调用 1--fopen
- 窗体自定义路径显示图片(Java)
- 2014年11月日本6日跟团游小结
- Tutorial 7 Rotation Transformation
- android 日历动画的实现
- hdu 5272 Dylans loves numbers
- 系统调用 8--综合实例(txt_to_txt)
- Unity该插件NGUI学习(1)—— 环境结构