c++ - Getting a byte value using stringstream -
To get rid of stringstream and store it in a byte-size variable, I got the wrong code (html)
(It should be in a byte ware, none):
#include & lt; Iostream & gt; # Include & lt; Sstream & gt; using namespace std; Int main (int argc, char ** argv) {stringstream ss ("1"); Unsigned four c; SS & gt; & Gt; C; Cout & lt; & Lt; (Int) C & lt; & Lt; Endl; }
When I run it, then it is 49, which I would not like to see. Obviously, this is considered as a four and there is no ordinary numerical value.
"post-text" itemprop = " The text ">
most certainly reads the value of the parse value in another integer type C ++ - and then is a byte Enter the type (Reading in a char
will never be parsed) - it always reads the next character:
typedef unsigned char byte_t; Unsigned int value; SS & gt; & Gt; value; If (value> numerical_litts & lt; byte_t>: max ()) {// error ...} byte_tb = static_cast & lieutenant; Byte_t> (Values);
I used the unsigned int
because it is the most natural, although unsigned short
will certainly work as well.
Comments
Post a Comment