Sign in to follow this  
xSKOTTIEx

writing to void pointers

Recommended Posts

xSKOTTIEx    174
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!

Share this post


Link to post
Share on other sites
xSKOTTIEx    174
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*

Share this post


Link to post
Share on other sites
SirKnight    316
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this