I want to convert:
A simple
unsigned char []tostringThen again to unsigned char
This is my code:
// This is the original char unsigned char data[14] = { 0x68,0x65,0x6c,0x6c,0x6f,0x20,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x72, }; // This convert to string string str(data, data + sizeof data / sizeof data[0]); // And this convert to unsigned char again unsigned char* val = new unsigned char[str.length() + 1]; strcpy_s(reinterpret_cast<char *>(val), str.length()+1 , str.c_str()); The problem is with the 2nd part, It wont convert the string to unsigned char like it was before. I think this img from locals in debug helps
valdoes contain a copy ofdata. Visual Studio's debug window is just not showing it as an array. If you addval,14to your watch list, it will be shown as an array.valsomewhere and it must be exactly likedata