mardi 15 décembre 2020

Is there an function in C++ for picking numbers inside a string

I have a calculator from stacks in c++, and when i try to insert a formula on it like 1+2*3 I wish i had a function that would get the numbers until each character that isn't a number. Example 12+2 it would get 12, then would skip the + because the code would get in other section and then again get the number 2. I made something like

for(i=0;i++;i<string.size();)

 {
    if(string[i]<48)
    character(string[i]);
    else if (string[i]>=48)
    number(string[i]);
 }

But this isn't efficient, someone knows a function for it?

Aucun commentaire:

Enregistrer un commentaire