The functions that convert string
s to floating-point types each receive two parameters:
• A string
containing the characters to convert.
• A pointer to a size_t
variable where the function stores the index of the first character that was not converted. The default argument is a null pointer, in which case the function does not store the index.
Consider an example of converting a string
to an floating-point value. Assuming the string
:
string s( "123.45hello" );
the following statement converts the beginning of the string
to the double
value 123.45
and stores that value in convertedDouble:
double convertedDouble = stod( s );
Again, the second argument is a null pointer by default.