Persistent ios::setw()

Discussion in 'C++' started by Martin Magnusson, Jul 13, 2004.

  1. Sending setw() to an ostream (for formatting numerical output etc.) only
    affects the next field. Is there no way to set width and padding more
    permanently?

    Thanks,
    martin
     
    Martin Magnusson, Jul 13, 2004
    #1
    1. Advertising

  2. Martin Magnusson

    Mike Wahler Guest

    "Martin Magnusson" <> wrote in message
    news:3dRIc.4909$...
    > Sending setw() to an ostream (for formatting numerical output etc.) only
    > affects the next field. Is there no way to set width and padding more
    > permanently?


    'width(0)' is called automatically after insertions.
    The fill character remains the same until explicitly
    changed.

    -Mike
     
    Mike Wahler, Jul 13, 2004
    #2
    1. Advertising

  3. Martin Magnusson

    Fraser Ross Guest

    Write an overloaded operator for insertion. I am not sure what happens for
    built-in types since there is already overloaded functions for them. It is
    a tricky function to write. Normally it returns a reference to the stream
    and it is a friend.

    Fraser.
     
    Fraser Ross, Jul 13, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthew David Hills

    input streams, setw(), and strings vs. char*?

    Matthew David Hills, Sep 5, 2003, in forum: C++
    Replies:
    1
    Views:
    584
    John Harrison
    Sep 5, 2003
  2. Marc Schellens

    setw, width

    Marc Schellens, Oct 6, 2003, in forum: C++
    Replies:
    1
    Views:
    605
    Attila Feher
    Oct 6, 2003
  3. Alex Vinokur

    width() and setw()

    Alex Vinokur, Nov 4, 2003, in forum: C++
    Replies:
    0
    Views:
    572
    Alex Vinokur
    Nov 4, 2003
  4. cout with setw ?

    , Nov 2, 2005, in forum: C++
    Replies:
    2
    Views:
    449
  5. gk
    Replies:
    7
    Views:
    983
    Tom Anderson
    Oct 12, 2010
Loading...

Share This Page