stoi
is for converting signed 32 bit integer whose maximum value it can hold is 2,147,483,647. You should catch the out_of_range exception thrown from
stoi
. And please remove the commas in your number string.
std::stoi, std::stol, std::stoll - cppreference.com[
^]
Another alternative is to use string streams to convert your strings to numbers.
#include <sstream>
#include <iostream>
int main()
{
unsigned int n = 0;
std::istringstream oss("4294967295");
oss >> n;
std::cout << n << std::endl;
return 0;
}