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" to m_Test.
how to do it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Firstly, the array has to be at least big enough to hold the string:
then you use strcpy. You need to cast the first parameter to avoid a warning:
Or if you want to be a C++ purist:
If you want to initialise the string rather than assign it, you could also say: