Valhalla Legends Forums Archive | C/C++ Programming | Quick CopyMemory Question

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

VB:
[code]
'MakeWORD
Dim Result As String * 2
CopyMemory ByVal Result, Value, 2
[/code]

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

C++??
[code]
// If this is wrong please tell me why
char Result[1]; // 0-1 (2)?
CopyMemory( Result, Value, 2 );
[/code]
May 21, 2004, 12:06 AM
K
[code]
WORD wValue = 0xabcd; // or unsigned int
BYTE bResult[2]; // or unsigned char / char.

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

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.
May 21, 2004, 12:25 AM
Eli_1
Ok, thanks.

Blah and I knew about arrays too. That was just a stupid mistake. :(
May 21, 2004, 12:29 AM

Search