Thread: Formatting output into even columns?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    11

    Formatting output into even columns?

    Hey guys, quick question. Is there anything in C (working in Linux here) that allows you to format output into even looking columns even if the corresponding output is printed horizontally? ..err, that's hard to explain. Basically I've got some code that performs DNS lookups on a list of machines (functionality is irrelevant to my question) and outputs the results. Right now, the output might look something like this:

    Code:
    host.domain.com              12.12.12.12
    host123.domain.com              123.123.123.123
    h.domain.com              21.21.21.21
    blah.domain2.com              32.32.32.32
    aaa.domain.com              111.111.111.111

    while it displays the right information, the output of the program as you can see is uneven and looks generally sloppy. What I'd like to do is have it's output look more like:

    Code:
    host.domain.com                 12.12.12.12
    host123.domain.com           123.123.123.123
    h.domain.com                      21.21.21.21
    blah.domain2.com               32.32.32.32
    aaa.domain.com                  111.111.111.111
    so that even though the data that goes together (host -- ip) is printed horizontally, columns of the text are outputted evenly. Is this possible ? Thanks.

    --EDIT--:
    In the example of how I want the output to look it still came out uneven, I guess thanks to how the forum parses my thread. Trust me though, the first number in the first octect of each IP in my example all line up >_<
    Last edited by Uncle Rico; 08-16-2005 at 04:31 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. formatting output
    By kisiellll in forum C Programming
    Replies: 2
    Last Post: 04-04-2009, 03:53 PM
  2. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 03:08 PM
  3. Output Columns form a file
    By Cdrwolfe in forum Tech Board
    Replies: 2
    Last Post: 03-22-2006, 05:12 AM
  4. Base converter libary
    By cdonlan in forum C++ Programming
    Replies: 22
    Last Post: 05-15-2005, 01:11 AM
  5. formatting output
    By spliff in forum C Programming
    Replies: 2
    Last Post: 08-14-2001, 06:50 PM