Converting numbers to strings

The <string> library provides various overloads of the to_string function to convert integer types and floating point types into a string object. This function does not allow you to provide any formatting details, so for an integer you cannot indicate the radix of the string representation (for example, hex), and for floating point conversions, you have no control over options like the number of significant figures. The to_string function is a simple function with limited facilities. A better option is to use the stream classes, as explained in the following section.

Get Beginning C++ Programming 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.