/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <stdio.h>
#include "fcntl.h"
struct free_bitmap{
int *node_bitmap;
int *data_bitmap;
};
int main()
{
struct free_bitmap f1;
struct free_bitmap f2;
f1.node_bitmap = (int *) malloc( sizeof(int) * 20 );
f1.data_bitmap = (int *) malloc( sizeof(int) * 128);
int i;
for(i=0;20>i;++i)
f1.node_bitmap[i] = i;
void * fblock = (void *) malloc(256);
memcpy((char*)fblock,(void*) &f1 ,256 );
int fd = open("test",O_RDWR|O_CREAT, 0600);
write(fd,fblock,256);
free(fblock);
printf("a");
fblock = (void *) malloc(256);
lseek(fd, 0, SEEK_SET);
read(fd,fblock,256);
f2.node_bitmap = (int *) malloc( sizeof(int) * 20 );
f2.data_bitmap = (int *) malloc( sizeof(int) * 128);
memcpy( (void*) &f2 , (char*)fblock , 256 );
free(fblock);
for(i=0;20>i;++i)
printf("%d " ,f1.node_bitmap[i]);
free(f2.node_bitmap);
free(f2.data_bitmap);
return 0;
}