You give fread() the memory where is should place the read bytes, it doesn't return a pointer.
Also, you're previous code snipet declares an array of pointers, not an array of structs...
Study this code:
Code:
struct test *testPtrArray[100];
struct test testArray[100];
printf("size of arrays: testPtrArray:%d, testArray:%d\n",
sizeof(testPtrArray),sizeof(testArray));
printf("size of elements: testPtrArray:%d, testArray:%d\n",
sizeof(testPtrArray[0]),sizeof(testArray[0]));
So if you don't want to use malloc(), you can use the "testArray" declaration which will allocate space for 100 structs on the stack.
Then you can use fread() like this:
Code:
fread(&(testArray[i]),sizeof(struct test),1,f);
gg