How to list file in a special format?

This is a discussion on How to list file in a special format? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I want to list file in two or three columns ? just like what UNIX does (ls) I've tried to ...

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    85

    How to list file in a special format?

    I want to list file in two or three columns ? just like what UNIX does (ls)
    I've tried to use TAB, but failed.
    Please help

  2. #2
    Registered User raimo's Avatar
    Join Date
    Jun 2002
    Posts
    107
    You have to see what is the biggest length of a filename in each column and then add enough spaces to make every name that long. Be sure that you know how many columns will fit before printing.

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    85
    You have to see what is the biggest length of a filename in each column and then add enough spaces to make every name that long. Be sure that you know how many columns will fit before printing.
    How about two column, and the filename is fit ?
    My code ? just add a \t when i is even in "for"
    but some filename is too short, for example IO.sys, then the filename in the same line(the next file) will move to left.

  4. #4
    Registered User raimo's Avatar
    Join Date
    Jun 2002
    Posts
    107
    but some filename is too short, for example IO.sys, then the filename in the same line(the next file) will move to left.
    If this is the only problem, then you only need to check if the filename is longer that the length of the tab and remove tabs according to that.
    ...
    But what if the filenames are too long?

  5. #5
    Registered User
    Join Date
    Jul 2002
    Posts
    85
    Originally posted by raimo

    If this is the only problem, then you only need to check if the filename is longer that the length of the tab and remove tabs according to that.
    ...
    But what if the filenames are too long?
    Thanks your opinion!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 05:27 PM
  2. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 09:39 AM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 11:21 PM

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