samedi 20 février 2021

How do I use stof to tackle only parts of the string at a time?

Assuming I have something like this

 int temp;
 string s = "5 + 6";
 for (int i = 0; i < s.length(); i++)
 { 
     if (isdigit(str[i]))
     {
           temp += stof(str[i],0);
     }
 }

How do I use stof so that I can access different positions of str and store it?

Aucun commentaire:

Enregistrer un commentaire