linux(fedora)遇坑笔记..持续更新..
#include <stdio.h>#define SIZE 1024int main(void){//文件大小为2KB 正好2048字节FILE * file=fopen("temp_","r+");char * buf[SIZE*2];int item_count=fread(buf,2,SIZE/2,file); //这边一共将会最多读取1024个字节 2*(1024/2)printf("count:%d\n",item_count); //item数512 item大小为2下 返回512(一共1024字节被读出)item_count=fread(buf,1,SIZE,file); //这边一共将会最多读取1024个字节 1*1024printf("count:%d\n",item_count); //item数1024 item大小为1下 返回1024(一共1024字节被读出)item_count=fread(buf,1,SIZE,file);printf("count:%d\n",item_count); //读完了 返回0printf("eof?%s\n",feof(file)==0?"false":"true");fclose(file);return 0;}
?
?