rendered paste bodyserialise.c:
#include <stdio.h>
#include <strings.h>
#include <stdlib.h>
struct test { int asd; int asd2;};
int main(){
struct test *seri = malloc(sizeof(struct test));
seri->asd = 3;
seri->asd2 = 5;
FILE *f_ptr = fopen("1serial.txt", "w+");
fwrite(seri, sizeof(struct test), 1, f_ptr);
sync();
struct test *seri2 = malloc(sizeof(struct test));
seri2->asd = 1; seri2->asd2 = 1;
fread(seri2, sizeof(struct test), 1, f_ptr);
fclose(f_ptr);
printf("%d should = %d\n", seri2->asd, seri->asd);
}
1serial.txt:
`hexdump -d 1serial.txt`
0000000 00003 00000 00005 00000
0000008