The reverse problem of formatting numbers for output is parsing numbers from the user's input. Parsing is intrinsically much more subtle and difficult than formatting, because we must account for the possibility of error. Every number can plausibly be turned into a string of digits, but not every string (or even every string of digits!) can plausibly be turned into a number. So, any function that purports to parse numbers must have some way of dealing with strings that do not represent valid numbers.
Consider the following declarations:
std::istringstream iss;
std::string str = "42";
char buffer[] = "42";
int intvalue;
float floatvalue;
int rc;
char *endptr;
size_t endidx;
std::from_chars_result r;
To convert the string in buffer or str to an intvalue integer, C++17 offers us the following options...