When I try to convert an int to string it produces weird results which I don't know where it comes from, here's a code snippet:
if (!ss.fail() && !ss.eof()) {
ss.clear();
string operand1 = "" + num1;
string operand2 = "";
getline(ss,operand2);
operand2 = trim(operand2);
cout << num1 << endl << operand1 << endl;
return expression_isvalid(operand1) && expression_isvalid(operand2) && operator_isvalid(c);
}
ss is a stringstream, num1 is an int, while c is a char.
basically the input is an expression like "1 + 1", num1 contains the first int it finds in that expression (using ss >> num1)
what I don't get is that this part
string operand1 = "" + num1; // assume input is "1 + 1" so num1 contains the value 1
...
cout << num1 << endl << operand1 << endl;
outputs
1
exit
I have no idea where the "exit" comes from, the word changes depending on the input, "exit" becomes "it" when I input "3+1", and "ye," when I input "13+2".