C++: How to tell if a string is actually an int

Channel:
Subscribers:
2,650
Published on ● Video Link: https://www.youtube.com/watch?v=JFmU0KSBKFE



Duration: 4:24
213 views
5


Suppose you have these strings:
"100"
"Hello"
"9Gag"
"Love4All"

Which of them can be converted to an int by stoi? The rule is: the first character in the string must be an int. So if (isdigit(s.at(0))) will be true if it can be converted.