#include <stdio.h>
#include <string.h>
int main()
{
FILE *fp=NULL;
int nRet = 0;
char readBuff[12];
memset(readBuff,0,12);
char *writeBuff = "hello world";
fp = fopen("mm","r+");
if(fp == NULL){
printf("open failed \n");
return -1;
}
printf("open success \n");
nRet =fread(readBuff,4,2,fp);
if(nRet <=0){
printf("fread failed \n");
return -3;
}
printf("fread success \n");
nRet = fwrite(writeBuff,4,1,fp);
if(nRet <=0){
printf("fwrite failed \n");
}
printf("fwrite success \n");
nRet = fclose(fp);
if(nRet){
printf("close failed \n");
return -4;
}
printf("close success ! \n");
}
linux的fwrite函数使用
最新推荐文章于 2024-07-20 18:38:43 发布