2009-10-14, 11:19 AM
Code:
#include <stdio.h>
struct myStruct
{
int a;
int b;
};
int main(void)
{
FILE* foo;
struct myStruct bar;
foo = fopen("foobar.txt", "rb");
fread(&bar.a, 4, 1, foo);
fclose(foo);
printf("%d\n", bar.a);
return 0;
}The program generates a runtime exception when executing the fread() command. What's the correct way to do this?
