2010-01-21 100 views

回答

4

大多数平面文件数据库都是用C++编写的。这是明确的证据,这是可能的。

创建自己的文件非常容易,特别是如果可移植性 - 将生成的文件移动到另一台计算机或将其用于另一个计算机编译程序的功能 - 不是必需的。

struct my_record_t { 
    ... 
}; 

int read(my_record_t& rec,size_t idx,FILE *f) { 
    if(0 > fseek(f,idx*sizeof(rec),SEEK_SET)) 
     return -1; 
    if(1 != fread(&rec,sizeof(rec),1,f)) 
     return -1; 
    return 0; 
} 

int write(my_record_t& rec,size_t idx,FILE *f) { 
    if(0 > fseek(f,idx*sizeof(rec),SEEK_SET)) 
     return -1; 
    if(1 != fwrite(&rec,sizeof(rec),1,f)) 
     return -1; 
    return 0; 
} 
+0

嗯,我认为他们只在php中使用对不起 – H4cKL0rD 2010-01-21 07:54:23

相关问题