• Welcome to Valhalla Legends Archive.
 

Quick CopyMemory Question

Started by Eli_1, May 20, 2004, 07:06 PM

Previous topic - Next topic

Eli_1

Just wondering how to use CopyMemory like the PacketBuffer class uses it.

VB:

'MakeWORD
Dim Result As String * 2    
CopyMemory ByVal Result, Value, 2


How do I do the String * 2 in C++, or is that not needed?

C++??

// If this is wrong please tell me why
char Result[1]; // 0-1 (2)?
CopyMemory( Result, Value, 2 );


K

#1

WORD wValue = 0xabcd; // or unsigned int
BYTE bResult[2]; // or unsigned char / char.

memcpy(bResult, wValue, 2); // or CopyMemory.


edit: for arrays, the number inside the brackets indicates how many elements are in the array.  the indeces of the array are from 0 to that number minus one.

int myarray[15]; has indeces of 0-14 for a total of 15 items.

Eli_1

Ok, thanks.

Blah and I knew about arrays too. That was just a stupid mistake.  :(