array of pointers to structs
I have created a struct, saved 100 entries of that struct into a file and will need to sort them by what ever means. I understand you can create an array of pointers to that struct like this:
Code:
struct test {
int testDataNum;
char testDataName[50];
};
struct test *testPtr[100];
Now, say I have already loaded 100 entries into a file using fseek(), fwrite() according to sizeof(struct test). My question is; is there a way to read these entries using something like fread() and put their address(to the beginning of the struct) into the array of pointers? fread() returns the actual data according to the size specified, not the location. I want to be able to sort the array of pointers, dereferencing them, so I dont have to creat this huge multidemensional array then sort that. I only need to print out the sorted list, the information can stay unsorted in the file. How would I get the address of each struct in the file?