char/unsigned char
types are an equivalent of byte
in Java or other languages.
std::string
has method c_str()
, which returns char*
with the length of std::string::size()
. char*
, being a c-string, can be considered as a full and complete binary representation of the underlying string.
Basically,
std::string s;
const char* s_data = s.c_str();
// do what you want with s_data
If all you want is an access to characters, using operator[] is enough:
char p = s[i]; // process that p as you want!
Information, provided here, should be enough for any kind of interaction with strings.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…