0

I have two arrays:

array<String^>^ lub=gcnew array<String^>(24);
const unsigned char *lb[24];

I want to copy the values from the first array, lub into lb; How can i do it? What conversion methods do I need to use?

ecatmur
  • 152,476
  • 27
  • 293
  • 366
  • possible duplicate of [Need to convert String^ to char \*](http://stackoverflow.com/questions/2178023/need-to-convert-string-to-char) – Leo Chapiro Jul 25 '14 at 10:53
  • Check `std::string::c_str()` and use `std::strcpy` to copy the strings. – a_guest Jul 25 '14 at 10:53
  • A String holds Unicode characters. What do you want your `unsigned char *` to hold?; presumably a 0-terminated sequence of characters but what character set and what encoding? Unicode/UTF-8, one of the ANSI character sets, or the system default would be good answers. How is the memory for each string allocated, who owns it, what's its lifetime and is it be shared? – Tom Blodget Jul 27 '14 at 01:51
  • Hei so I want my unsigned char * to hold UTF-16, like 0xEF. So if you could help me with that I would really appreciate it. – user3828865 Jul 28 '14 at 06:49
  • I am working with .net classes. My string values come from textboxes in which I introduce HEXadecimal values, like(3f,4e ..). I have to convert them to unsigned char in order to work with thw values and after return them to textboxes. I hope it makes sense what I'm saying – user3828865 Jul 28 '14 at 07:09
  • See my solution in [Need to convert String^ to char *](http://stackoverflow.com/questions/2178023/need-to-convert-string-to-char). Basically, you can use `sprintf()` to convert from `String^` to `char *`. – Ionian316 Jan 23 '15 at 18:13

0 Answers0