This is my code
for (unsigned int i = 0; i < form.size(); i++)
if (isdigit(form[i]))
{
value=form[i] - '0';
operand.push(value) //this is a stack
}
but it only works when you have an int of 1 digit, lets say the form string has 1, it works just fine, but when the string gets 10, it won't work because it will set value first into 1 then into 0 and wont get the number 10, is there a way to do it inside the for loop? I can't use atoi because sometimes the string can have characters like '/' or '*' and i need to place them in another stack. i would like to know if there is a way to get the value variable to contain the integer 10.
Aucun commentaire:
Enregistrer un commentaire