__gc array from string constant?

P

Paul Steckler

I'm using a managed C++ class that wants an
unsigned char __gc[] as input. Is there a
way to easily populate that array from a
string constant (or wide string constant, etc.)?

I'd like to do something like:

unsigned char foo __gc[] = "your ad here";

but of course that doesn't work.

Any suggestions welcome.

-- Paul
 
J

Jacky Kwok

Paul said:
I'm using a managed C++ class that wants an
unsigned char __gc[] as input. Is there a
way to easily populate that array from a
string constant (or wide string constant, etc.)?

I'd like to do something like:

unsigned char foo __gc[] = "your ad here";

but of course that doesn't work.

Any suggestions welcome.

-- Paul

Two method, depends on what is the "char" you want. Note, the character
in DotNet is 16 bits.

char str __gc[] = System::Text::Encoding::ASCII->GetBytes(S"Hello
World"); //return 8 bits bytes

unsigned short wstr __gc[] = (S"Hello World")->ToCharArray(); //return
16 bits characters
 

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