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
Tight_Coder_Ex
17
Posting Whiz in Training
Recommended Answers
Jump to Postsorry but cant you use setwidth function ? Or something similar?
Jump to PostThat 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?
All 5 Replies
Acidburn
0
Posting Pro
Tight_Coder_Ex
17
Posting Whiz in Training
Acidburn
0
Posting Pro
Dave Sinkula
2,398
long time no c
Team Colleague
Tight_Coder_Ex
17
Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.