0

I'd like to read a floating point value cin >> Value where Value is declared as a double and then output it to a string justified to two decimal places. I understand how to do it using a temporary file, but I'd like to avoid that method and sprintf() if possible

3
Contributors
5
Replies
6
Views
12 Years
Discussion Span
Last Post by Tight_Coder_Ex
0

sorry but cant you use setwidth function ? Or something similar?

That accomplishes the formatting I want, but still doesn't solve the problem of assigning it to a string variable.

0

That accomplishes the formatting I want, but still doesn't solve the problem of assigning it to a string variable.

Not sure if I know what I'm talking about here, but couldnt you put your double / float into an array then convert the array to a string?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.