I want to get a substring from a string . I do this in new for_each loop with lambda and string.substr() .for the first time ,it runs correctly but after that it don't work correctly
here is my code:-
suppose eqn = "1231-78*78-433-67+89/32" and
std::for_each(eqn.begin(),eqn.end(),[&](char ch)
{
if(isdigit(ch) || ch=='.')
i++;
else if(isOperator(ch))
{
std::string temp = eqn.substr(li,i);
double tempN = std::stod(temp);
NumOp.insert(std::pair <double ,char> (tempN,ch));
li=i+1;i++;
}
});
now here is what I see in my QtCreator's debug:-
it should give me "78*" substring from string "1231-78*78-433-67+89/32" but i am getting "78*78-4" which is causing so much destruction and I can't figure out.please help me cause I was like waking since all night
Aucun commentaire:
Enregistrer un commentaire