Thread: 2 outfile questions

  1. #1
    Registered User
    Join Date
    Feb 2010

    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?

  2. #2
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    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,
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

  3. #3
    Registered User
    Join Date
    Feb 2010
    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!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. malloc problem
    By Tool in forum C Programming
    Replies: 23
    Last Post: 03-12-2010, 10:54 AM
  2. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  3. Conflicting types of typedef error
    By advocation in forum C++ Programming
    Replies: 4
    Last Post: 03-22-2005, 06:26 PM
  4. Trivial questions - what to do?
    By Aerie in forum A Brief History of
    Replies: 23
    Last Post: 12-26-2004, 09:44 AM
  5. can someone check this out and let me know ?
    By javaz in forum C Programming
    Replies: 5
    Last Post: 01-21-2002, 02:13 PM