D
DamonChong
Hi,
I am trying this in my code and getting strange answers. Would
appreciate if someone can point out what it is i'm missing here. My
thanks in advance.
-------------code snippets--------------
// where str is a std::string variable
std::bitset<4> size;
size.reset();
size |= std::atoi( (str.substr(pos,4)).c_str() );
std::cout << "next - <" << str.substr(pos,4) << ">, after convert - "
<< size.template to_string<char,
std::char_traits<char>,std::allocator<char> >();
------------output to console-----------
size - <0110>, after convert - 1110
----------end of output---------------
Above is the output i get. Notice i am expecting after convert to show
0110 but instead i get 1110!! BTW, i'm using VC++ Toolkit 2003.
Hmmmm.....
I am trying this in my code and getting strange answers. Would
appreciate if someone can point out what it is i'm missing here. My
thanks in advance.
-------------code snippets--------------
// where str is a std::string variable
std::bitset<4> size;
size.reset();
size |= std::atoi( (str.substr(pos,4)).c_str() );
std::cout << "next - <" << str.substr(pos,4) << ">, after convert - "
<< size.template to_string<char,
std::char_traits<char>,std::allocator<char> >();
------------output to console-----------
size - <0110>, after convert - 1110
----------end of output---------------
Above is the output i get. Notice i am expecting after convert to show
0110 but instead i get 1110!! BTW, i'm using VC++ Toolkit 2003.
Hmmmm.....