c语言断点续传

bool DealFile(string fileName) //随便写个函数说明
{
FILE *file;
DWORD fileSize ,pos;
int readLen ;

//MAX_BUFFER_LEN 在头文件里定义,这里能够保证数据不丢失,也不至于内存逸出
char *buffer = new char[MAX_BUFFER_LEN];
file = fopen(fileName.c_str(),"r+b");
  if(file == NULL) return false;
fseek(file,0,2);
fileSize = ftell(file); //取得文件的大小
fseek(file,0,0);
do{
readLen = fread(buffer,sizeof(char),MAX_BUFFER_LEN,file);
if(readLen > 0)
{
pos += readLen;
//对读取的文件做处理
}
}while(pos < fileSize); //循环读取文件
 delete[] buffer;
fclose(file); //释放资源
return true;

}
原文地址:https://www.cnblogs.com/zzxap/p/2175783.html