ok, begin long question:
here's what i want/need to do. begin pseudocode:
//Now, say i have a function that accepts a void*, an unsigned int, and another unsigned int.........::
void GrabData(void* GrabbedData, unsigned int beg, unsigned int Size)
// Now, we want to be able to pass any type of variable to "GrabbedData", specify a begin positon, and the size of the variable in bytes.
// Once we've passed that, the code should do this:
Look in the FileData (which is a separate void* variable elsewhere that has already been given data) and set the "get" position to "beg"
grab <Size> data and set it to <GrabbedData>
now, say we have an unsigned int and a file that has about 8 bytes in it. Say the file was like so: (in hex)
now, say we set beg to 2, and pass the unsigned int with a sizeof(unsigned int) for the "Size" variable
when you call the function, it should get that data from the "FileData" variable, and since it's a pointer, automatically change the value of the passed variable.
in a sense this works the same was as fread, whereas you pass a pointer to a variable, the size in bytes, and the number of variables to get (in case you have an array or whatever). that is the same thing i want to achieve, except i need to do it with a void* variable (FileData) that already has data in it (which was read from a file)
this way i can read from an internal variable and not have to worry about constantly accessing the file itself.
If anyone knows how to do this (or just knows how fread works), please post here.
*begins searching in google for documentation on how fread works.......*
*returns from google search without finding much.......*
buffer is your destination buffer, where you want the data to go.
size_t fread (void *buffer, size_t width, size_t count, FILE *file_pointer)
width is how big your unit of data is. (If you use a char* in the first argument, it'll be one byte.)
count is how many units you want
the file pointer is the file you're reading from.
fread returns the amount of units it could successfully read.
i already know how to use that, i use it to read all the data in right away! lol
what i need to do is read the data from the void* that already has data it is pointing at.....