I have a function which reads a binary file into memory as type void *. Information in the file header indicates the amount of memory required and the actual data type (in bytes per number - eg. 8 if it should be interpreted as "long".
My problem is, main has no knowledge of the data type or memory required. So I call the function like this:
long myfread(char *infile, void **tempdata,*datasize)
char *infile="data.bin"; // name of the input file
void *tempdata=NULL; // where the data will be stored, initially
long n; // total numbers read, returned by the function
size_t datasize; // modified appropriately by the function
n = myfread(infile,&tempdata,&datasize);
So far so good - main can read the bytes in "tempdata" - but not as (say) integers or floats. My question is, is there a simple way to recast tempdata to make this possible?