writing to void pointers
I'm trying to do some binary input and output on a file for game databasing, and I'm using a buffer pool to prevent reading times for information that may already be in memory. But because the information in the file can vary depending on where it is, I've opted for void* as the transfer from the buffer pool to the client.
Basically: given a void*, how do I copy binary information into it?
Thanks in advance!
but what if the bytes lay down into a structure, like a structure of ints?
i could do this
IntStruct* struct = new IntStruct();
get( struct );
where the parm is a void*
i could do this
IntStruct* struct = new IntStruct();
get( struct );
where the parm is a void*
Before you write, you need to cast back to the original type.
So in your structure example:
void get( void *p )
{
IntStruct *is = (IntStruct*)p;
copy( is, data );
}
-SirKnight
So in your structure example:
void get( void *p )
{
IntStruct *is = (IntStruct*)p;
copy( is, data );
}
-SirKnight
Of course you could always cast to char* and copy byte-by-byte. It wouldn't matter if you're using a structure or not.
-SirKnight
-SirKnight
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement