Comparing C-style strings with ==
means "Do the first elements of these strings have the same address?". It doesn't actually compare the contents of the strings. For that, you need strcmp
.
However, you have no reason to compare C-style strings - just use the std::string
returned from str()
, which can be compared using ==
, like so: input.str() != "0"
.