-
2 outfile questions
I got two question about fomatting output to a file.
1st question concerns justifying. I found "right" and "left" in the library to justify right and left, but is there an equivalent to center in a column?
2nd I am trying to round to 2 decimal places so i used setprecision(3). It works great when i input a number like 1.2111111, ie i get 1.21. But i have an issue when i input something like 2.1. I would like to get 2.10 out of it, but I guess I am doing it wrong.
Any advice?
-
1. I don't believe so. What you can do is convert to string, and based on the length and the width you want, figure out how many spaces to pad with.
2. You can use fixed. For example,
Code:
file<<fixed<<setprecision(2)<<value;
-
Thanks for the reply. I was afraid you were going to say that abuot number 1, but no biggy. Number two worked like a charm. I appreciate it!