Thread: Custom tab and space types/definitions

  1. #1
    Unregistered
    Guest

    Custom tab and space types/definitions

    Hello. I would like to save space in my coding by having a custom-defined tab and space characters. I once had an example of a way to do this, but I forgot and I cannot find another example anywhere on the Internet. The following is an illustration of my idea:

    cout<<"\t\t\t\t\t\t\t\t\tHELLO";
    v.
    cout<<tab(9)<<"HELLO";

    Both lines would have the same output, only the second line would be easier to code and friendlier to space-saving say if you wanted 100 tabs. I think I would be able to figure out how to do the same for space, "-", etc. if someone could show me how to do this tab example.

    I thought I remember something like: typdef char tab[] = ' '; or something similar.

    Thank you very much for the help; this will be a lifesaver because at one point in my program, I have like 13 tabs and >100 "-" (dashes). Thanks again!

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    use setw() and setfill() from <iomanip> or <iomanip.h>
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tab
    By Utopus in forum Tech Board
    Replies: 1
    Last Post: 06-23-2007, 08:09 AM
  2. Replies: 4
    Last Post: 10-14-2005, 12:53 PM
  3. Replies: 5
    Last Post: 06-30-2003, 12:52 PM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM