Sign in to follow this  
lomateron

moving array bits to another array of another type

Recommended Posts

ApochPiQ    23003

This is a really, really, really bad idea, and you should avoid it, but here's how it would work:

 

// Copy mouse data into info array
const char * pmouse = reinterpret_cast<const char *>(&mouses[0]);
std::copy(pmouse, pmouse + sizeof(RAWMOUSE * 2), &info[0]);
 
// Copy info array into mouse data
char * pmouse = reinterpret_cast<char *>(&mouses[0]);
std::copy(&info[0], &info[48], pmouse);

 

 

At the very least, use some static asserts to ensure that your RAWMOUSE size and the size of the info array are lined up correctly.

 

But yeah, you really just shouldn't do that. Depending on what you're trying to accomplish, there's basically guaranteed to be a better solution.

Share this post


Link to post
Share on other sites
lomateron    491

what I am doing is sending the raw mouse input of 2 mouse to another computer using datagram sockets.

sometimes the send() will send incomplete data and will tell me how many bytes of the data has been sent and I have to calculate how much is left and send the rest

so I have to pass the RAWMOUSE array to a char array so when I see that there are lets say 4 bytes left to send I can send them:

 

char info[48];

char* pointer;

pointer=info;

send(pointer);

 

//then I find that 44 of the 48 bytes were sent

pointer+=44;

send(pointer); 

 

ooHH!!I just need to use da "pointer" with "mouses" sorry now i know how to do it!!!

char* pointer;

pointer=mouses;  //mouses!!!!!<---------------------------------

send(pointer);

 

//then I find that 44 of the 48 bytes were sent

pointer+=44;

send(pointer); 

Edited by lomateron

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