... value divided by 2 is " << x / 2 << endl;
12  }

The string "1000000" converted to long int is 1000000
The converted value divided by 2 is 500000

Function strtod (Fig. 22.31) converts a sequence of characters representing a floating-point value to double. Function strtod receives two arguments—a string (char*) and the address of a char* pointer (i.e., a char**). The string contains the character sequence to be converted to double. The second argument enables strtod to modify a char* pointer in the calling function, such that the pointer points to the location of the first character after the converted portion of the string. Line 11 indicates that d is assigned the double value converted from string and that stringPtr is assigned the location of ...

Get C++ How to Program, 10/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.