How to set a character in C++?
This is probably very obvious, in fact so o开发者_Python百科bvious that no C++ reference I could find online cares to document it.
I need to know how to set the byte value of a char
in C/C++. For example, if I want the byte value 233 in the char, how do I do?
Yes, it is too obvious:
char x = 233;
A char is a 1byte int. So you can set the value in the same way as you would an int.
char c = 123;
char d = 0x12;
etc...
char x = 233;
Yea, literally as simple as that.
精彩评论