您的位置:首页 > 其它

库函数调用 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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: