How to convert a string literal to unsigned char array in visual c++

后端 未结 8 1514
闹比i
闹比i 2020-12-06 06:02

How to convert a string to Unsigned char in c++...

I have,

unsigned char m_Test[8];

I want to assign a string \"Hello world\"

8条回答
  •  遥遥无期
    2020-12-06 06:39

    You can use c_str() function of std::string to get the char* out of string. This method basically returns a pointer to c-style string. After this you can use the normal string copying functions such as strcpy or strncpy to copy the value in to test.

提交回复
热议问题