Listing 6

#include <stdio.h>
#include <inttypes.h>

struct on_disk
{
   /* ILP32|LP64 Sharing Issue: This should change to int32_t */
   long foo;
};
int main()
{
    FILE *file;
    struct on_disk data;
#ifdef WRITE
        file=fopen("test","w");
        data.foo = 65535;
        fwrite(&data, sizeof(struct on_disk), 1, file);
#else
        file = fopen("test","r");
        fread(&data, sizeof(struct on_disk), 1, file);
        printf("data: %ld\n", data.foo);
#endif
    fclose(file);
}