Setw question

This is a discussion on Setw question within the C++ Programming forums, part of the General Programming Boards category; I am wondering if there is a function or command that can be used like precision where once called it ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    25

    Setw question

    I am wondering if there is a function or command that can be used like precision where once called it will add a certain amount of spaces before all output until otherwise changed. Instead of having to put like setw(10) before each output

    Thanks,
    Van

  2. #2
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    hmm i don't think so, but you could probably use tab to trick it, like this:

    Code:
    cout <<setw(10)<<"\t This would setw to ten then tab in.";

  3. #3
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    You could go...

    #define coutw cout<<setw(10)

    Then call coutw << "Hello"; to indent 10 spaces. Or even:

    #define cout cout<<setw(10)

    Then call cout as you normally would.
    Last edited by Eibro; 10-15-2002 at 04:23 PM.

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    25
    Thank you Eibro I will have to give that a try.

    Van

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. setw question
    By dhrodrigues in forum C++ Programming
    Replies: 9
    Last Post: 07-14-2004, 09:34 AM
  2. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 01:52 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 10:47 PM
  4. Question about linked lists.
    By cheeisme123 in forum C++ Programming
    Replies: 6
    Last Post: 02-25-2003, 01:36 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21