As others have said, you are comparing raw pointers char*that have different addresses, since they come from different sources. To do what you are trying, you need to use std::string::operator==()instead to compare the contents std::stringand not compare the pointers (and also get rid of redundant calls std:stringstream::str(), all you do is lose memory this way):
void calc::AddToInput(int number)
{
std::string str = input.str();
MessageBox(NULL, str.c_str(), "Input", NULL);
if (str == "0")
input.str("");
input << number;
}
Or, if you also get rid of MessageBox():
void calc::AddToInput(int number)
{
if (input.str() == "0")
input.str("");
input << number;
}
source
share