I want to get x = 1,234,567,890.098,765,432,1
.
#include
#include
#include
#include
us
Here's an algorithm:
Create a function that takes the number to convert as its parameter. Convert that number to a string. Scan the string for a decimal point (while being aware of the possibility for non-numeric results like infinity or indefinite). If found, process the remainder of the string, inserting your separator character after every third digit, stopping when you reach the end of the string or a non-digit (for example, an E
to designate an exponent). Return this string.
As an additional exercise, create a version of this function that can be passed to cout
as a manipulator.