1

我想永远读取一个文件我怎样才能转到文件的开头
这是我的代码

FILE* inp_file=fopen("Input_file.bin","rb"); 
uint8* buffer; 
buffer=(uint8*)malloc(nSize);
uint32 nSize =1000;
while(1)
{
   while(! feof (inp_file))
     {             
         memset (buffer,'0',nSize); 
         fread (buffer,nSize,1,inp_file);
         Sleep(5);
     }
  //Here I want to go to the beginning of the file
}
4

2 回答 2

2

看看fseekSEEK_SET

另请注意

uint8* buffer; 
buffer=(uint8*)malloc(nSize);
uint32 nSize =1000;

应该

uint8* buffer; 
uint32 nSize =1000;
buffer=(uint8*)malloc(nSize);
于 2013-07-02T11:09:34.630 回答
0

以下似乎对你有用。祝你好运:)

FILE* inp_file=fopen("Input_file.bin","rb"); 
uint8* buffer; 
buffer=(uint8*)malloc(nSize);
uint32 nSize =1000;
while(1)
{
   while(! feof (inp_file))
     {             
         memset (buffer,'0',nSize); 
         fread (buffer,nSize,1,inp_file);
         Sleep(5);
     }
  rewind(inp_file);
}
于 2013-07-02T11:18:08.703 回答