I have a string like below:
std::string strl="ffffffffffffffffffffffffffffffffffffffffffff";
I want to convert it into uint32_t variable like below:
uint32_t val = std::stoul(strl, nullptr, 16);
The above operation gives a "SIGABRT" signal and gives error:
terminate called after throwing an instance of 'std::out_of_range'
what(): stoul.
What changes to be done for resolving the issue or it is not possible with uint32_t datatype to store the string.
uint32_tcan only store up to0xffffffffas it's a 32 bitunsignedtype, so it's not possible to store your string with that data type.For the string you present, you'll need a big integer library to parse it.
Boost has a good one, and even includes
typedefs likeuint1024_t, so it's very simple to use.See http://www.boost.org/doc/libs/1_58_0/libs/multiprecision/doc/html/index.html