Link to home
Start Free TrialLog in
Avatar of mendes paulo
mendes paulo

asked on

c++ char convert to string

HOW TO CONVERT * char to string (linha):

const unsigned char
*menino1 = (const unsigned char *)0;


menino1 = p - 17;

string linha = menino[1]+menino[2]+menino[3]+menino[4]+menino[5];
Avatar of pepr
pepr

Just use the std::string constructor and pass it the menino1.

http://www.cplusplus.com/reference/string/string/string/ See the variant (4) if your bytes are ended with zero or (5) passing the length -- this may be more suitable for your case... like
string linha(menino1, 5);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of sarabande
sarabande
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Detailed explanation provided. The answer is good source for learning.