How to add trailing zeros to integers?

Got it working, thanks everyone!
Last edited on
Round it, cast it to an integer, then print it out followed by the string ".00".

Or does that not work for you?
You already figured out how to round.

1
2
3
4
int round( double value )
{
    return( static_cast<int>( value + 0.5 ) );
}


And to output following 0's you can simply put a string as double main suggested

 
out << list2[i] << ".00" << endl;
I tried exactly what you guys suggested, but as soon as I put the ".00" in, my output only shows the first number being written; everything else is skipped.

If I take the ".00" out, everything works fine but of course without the decimal and trailing 0's.
Never mind, it's writing correctly, it's the reading part that isn't correct. I'll fix that.

Thank you very much everyone.
giblit you are right.
Last edited on
He wants to output the rounded value though yours will not round alee. Also why should he not do it that way?
Topic archived. No new replies allowed.