Created
January 5, 2010 01:02
-
-
Save zacbrown/269051 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
struct test { | |
int a; | |
int b; | |
int* c; | |
}; | |
void main() | |
{ | |
struct test blah; | |
blah.a = 5; | |
blah.b = 3; | |
blah.c = &blah.a; | |
printf("blah.a: %d | blah.c: 0x%08x | *blah.c: %d\n", blah.a, blah.c,*blah.c); | |
FILE *f = fopen("test.bin", "wb"); | |
fwrite(&blah, 1, sizeof(struct test), f); | |
fclose(f); | |
memset(&blah, 0, sizeof(struct test)); | |
struct test bloop; | |
f = fopen("test.bin", "rb"); | |
fread(&bloop, 1, sizeof(struct test), f); | |
fclose(f); | |
printf("bloop.a: %d | bloop.c: 0x%08x | *bloop.c: %d\n", bloop.a, bloop.c, *bloop.c); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment