Coping one array to another in Managed C++

G

Guest

How can I copy 5 bytes from the middle of one array to another in Managed C++?
The following code segment causes the compilation errors below:

unsigned char cResult __gc[] = new unsigned char __gc[256];
unsigned char cBuf __gc[] = new unsigned char __gc[256];
....
strncpy(cBuf, (cResult + 10), 5);

***********************************************

error C2690: '+' : cannot perform pointer arithmetic on a __gc array
error C2664: 'strncpy' : cannot convert parameter 1 from 'unsigned char
__gc[]' to 'char *'
Can only convert a __gc array to or from Object * or Array *

***********************************************

Can anyone clarify this situation, please.
 
M

mphanke

You could do something like this:

strncpy((unsigned char*)&cBuf[0], ((unsigned char*)&cResult[0])+10, 5);

This should also work IMO.

Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top