im new to c++ im having a problem comparing strings i want it to return true or false
code:
bool ope(string op)
{
if (op=="+" || op=="-" || op=="/" || op == "*" || op=="^"){
return true;
}
else{
return false;
}
}
int calculate(string p)
{
int first;
int second;
for(int i=0; i< p.length();i++){
if(ope(p[i])==true){ //<------- where my error is occuring
first = p[i-2];
second = p[i-1];
}
}
}
p[i] gives you a single character of the string p, but ope() takes a string as its argument. You could modify it to take character instead.