Functions That Convert strings to Floating-Point Types

The functions that convert strings 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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.67.177