Suppose I want to write a function:
int read_file (char *filename, void *abc)
that reads the file, and puts the numbers in an array, which abc
points to.
I must use the void pointer - I know how I would do it if it were int *abc
instead of void, as I could treat abc
syntactically like an array, and do stuff like abc[0]=1
, but here I can't do that, as it's a void pointer.
I'm not too familiar with void pointers, and how I should get this to work. Please help! I prefer not to post code, as this is for a school assignment, and just want to know how I would put the information in the file into an array pointed to by abc
, maybe with casting (not sure how to do that though).
I am already familiar with putting file information into an array, if it's given by int abc
.