I have a really simple program that converts a hex string to it's int value. The code seems fine, but it throws a runtime error:
terminate called after throwing an instance of 'std::out_of_range' what(): stoi
Here is the code where the error is being caused:
int dump[4];
string hexCodes[4] = {"fffc0000", "ff0cd044", "ff0000fc", "ff000000"};
for (int i = 0; i < 4; i++)
{
dump[i] = 0;
dump[i] = stoi(hexCodes[i], 0, 16);
cout << dump[i] << endl;
}
I have tried reading a couple of pages such as this. I still can't find anything that relates to my issue. What am I doing wrong that is causing this error?