开心每一天1111
我倾向于将整个缓冲区作为原始内存块加载到内存中并自行进行解析。这样我就能最好地控制标准库在多个平台上的作用。这是我用于此的存根。您可能还想检查fseek,ftell和fread的错误代码。(为清楚起见,省略)。char * buffer = 0;long length;FILE * f = fopen (filename, "rb");if (f){
fseek (f, 0, SEEK_END);
length = ftell (f);
fseek (f, 0, SEEK_SET);
buffer = malloc (length);
if (buffer)
{
fread (buffer, 1, length, f);
}
fclose (f);}if (buffer){
// start to process your data / extract strings here...
}