日期:2014-05-16 浏览次数:20931 次
#include <unistd.h> #include <stdio.h> #include <sys/mman.h> #include <fcntl.h> #include <stdlib.h> typedef struct{ int integer; char string[24]; }RECORD; #define NRECORDS (100) int main() { RECORD record,*mapped; int i,f; FILE *fp; fp = fopen("records.txt","w+"); for(i = 0;i < NRECORDS;++i) { record.integer = i; sprintf(record.string,"RECORD-%d",i); fwrite(&record,sizeof(record),1,fp); } fclose(fp); }