Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>formatting formatting an i/o stream</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 Formatting           Formatting an I/O Stream


            To format the data you send or receive in streams, you must
    either use a manipulator (see Manipulators) or change the value of
    one of the following flags (as in the stored in a long integer in
    the definition of the ios class in IOSTREAM.H):

    Flag        Value           Means
  ---------   ----------  ---------------------------------------------------
  skipws       0x0001     Skip whitespace upon input
  left         0x0002     Left-adjust the output
  right        0x0004     Right-adjust the output
  internal     0x0008     Padding after sign or base indicator
  dec          0x0010     Decimal conversion of data
  oct          0x0020     Octal conversion of data
  hex          0x0040     Hexidecimal conversion of data
  showbase     0x0080     Use base indicator upon output
  showpoint    0x0100     Force decimal point display
  uppercase    0x0200     Upper-case hex output
  showpos      0x0400     Add + sign to positive integers
  scientific   0x0800     Use E notation for exponents
  fixed        0x1000     Use fixed floating point notation
  unitbuf      0x2000     Flush streams after insertion
  stdio        0x4000     Flush both stdout and stderr after insertion

          To modify these flags, you can use the function setf(),
    declared like this: long setf(long flags). For example, you
    might use scientific notation and show the decimal point in cout
    output like this: cout.setf(ios::scientific | ios::showpos); where
    the correct flags have been ORed together. The opposite function
    is long unsetf(long flags).
          The int width(int len) function sets the current field
    width to len. The char fill(char ch) sets the current fill
    character (the default is a space) to ch. The int precision(int num)
    function sets the displayed floating point precision (the number of
    places after the decimal place) to num.

See Also: Manipulators

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson