I am trying to make a more advanced calculator where you enter a piece of algebra. I have this problem, the string that contains what you inputted doesn't test positive for '+' even when it does.
This is the code that tests the string
for(int i = 0; i < line.length(); i++)
{
if(pos == 0 && line[i] >= '0' && line[i] <= '9' || line[i] == '.')
{
p1[p1p] = line[i]; // setting the number to the current character
p1p++; // position of the first number
}
if(line[i] == '+')
{
pos++;
operation = 1;
cout << "add" << endl;
}
}
It will never out put + unless there is no space between the last character of the number and the + symbol
e.g. '100+10' would test positive for '+' but '100 + 10' wouldn't.
Thanks -Hugh