#include <stdio.h>
#include <stdlib.h>
int main() { FILE *file; file = fopen("./text","rb"); //获取文件长度 fseek(file,0,SEEK_END); int tell_len = ftell(file); fseek(file,0,SEEK_SET); char *buff = (char *)mem_get(char,tell_len+1); int read_len = fread(buff,len,1,file); printf("read file len = %d\n",file); //从文件中间读取1024个字节 int pos = tell_len/2; fseek(file,pos,SEEK_SET); char buf[1025] = "\0"; int len = freadd(buf,1024,1,file); printf("buf = %s\n",buf); return 0; }
原文地址:http://sysq2012cto.blog.51cto.com/8202674/1575425