Thread: Formula for justifying text?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    18

    Question Formula for justifying text?

    Hey does any one know of a (preferably simple) formula for justifying text into a column? Or maybe someone can fix mine?

    I have to write a prog in C to do this, I have the program all written out, but my output isn't as I would like it...

    I calculate the number of spaces that should be between each word in a line using this:

    spaces = ( m - c ) / (w - 1)

    where:
    m = maximum number of characters in line (e.g. column width)
    c = the number of characters in the line I want to print (basically a combination of the lengths of all the words in the line)
    w = number of words in the line

    I think a lot of my problem may lie in that this fraction wouldn't always be coming out to a whole number and you can print say .3 of a space...
    Last edited by nine-hundred; 09-02-2007 at 12:50 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Deleting Text from a Text file
    By Daved in forum C++ Programming
    Replies: 5
    Last Post: 11-04-2006, 09:47 PM
  2. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 04:49 PM
  3. Appending text to an edit control
    By dit6a9 in forum Windows Programming
    Replies: 3
    Last Post: 08-13-2004, 09:52 PM
  4. Scrolling The Text
    By GaPe in forum C Programming
    Replies: 3
    Last Post: 07-14-2002, 04:33 PM
  5. Replies: 1
    Last Post: 07-13-2002, 05:45 PM