pointer to a array<unsigned char>^

Jun 8, 2012 at 10:16am
Hi all,
c++
I have a buffer
array<unsigned char>^ buffer = gcnew array<unsigned char>(11);

I keep my data here to send to the serial port

I would like to call a function with a pointer to buffer

I tried:

// define class CRC
CRC df1;

df1.check_crc(&buffer, 4);

but obviously it can't convert buffer to a cli unsigned char.

the check_crc funtion in class CRC

unsigned char check_crc(unsigned char *buffer, unsigned char length)
{
unsigned char temp_crc =0;

for(unsigned char temp =6; temp < length+6; temp++)
{
temp_crc = check(temp_crc, *buffer);
*buffer ++;

}
return temp_crc;

}


anyone a idea?




Jun 8, 2012 at 11:15am
buffer is already a pointer. So you should specify it as argument.
Jun 8, 2012 at 1:24pm
yes but I can not convert a
array<unsigned char>^ buffer = gcnew array<unsigned char>(11);

into a function call like
unsigned char check_crc(unsigned char *buffer, unsigned char length)

so what would be the best solution?
Jun 8, 2012 at 1:46pm
closed account (1vRz3TCk)
jorz wrote:
so what would be the best solution?
Not to mix C++ and C++/CLI. ;0)

Jun 9, 2012 at 1:05am
Thanks codeMonkey,

are only array's managed variables or is it preferable to create normal int, char etc also as managed variables?

Last edited on Jun 9, 2012 at 4:17am
Topic archived. No new replies allowed.