c++ - Adding Chars to a Stringstream -
i trying add numbers char array stringstream object. code is:
char[50] buffer = '<15>'; stringstream str; int page; str << buffer[1]+buffer[2]; str >> page;
page should hold integer value of 15, instead holds value 102. idea wrong code?
change
str << buffer[1]+buffer[2];
to
str << buffer[1] << buffer[2];
the way code written, add characters '1' , '5', equal 49 , 53 respectively, 102 , output stream.
Comments
Post a Comment