2010-01-21 97 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

相關問題