vendredi 27 juillet 2018

C++ stoi: none of the 2 overloads could convert all the argument types

I am coding an exercise relating to string: Input a string (doesn't matter either char[] or C+11 string so I chose the latter) then find the longest (has most characters) ascending substring inside the given string. The idea that I have is scan through the whole string and compare str[i] with str[i+1]. I used stoi to convert each character into int, which looks like this

if (stoi(str[i]) < stoi(str[i+1]))

but it instead gave me error:

error C2665: 'std::stoi': none of the 2 overloads could convert all the argument types

How can I fix it ? Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire