LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Quick String Format Question (EASY) (https://www.linuxquestions.org/questions/programming-9/quick-string-format-question-easy-387008/)

Mistro116@yahoo.com 11-27-2005 01:54 PM

Quick String Format Question (EASY)
 
Let's say you want to format the Strings:

JOHN
BOB
TIM
TOMMY
MILWAK
JEFFERSON
15LETTERWORD

And you wanted to format these strings to 15 spaces, so have them like up like

john starthere
bob starthere
tim starthere
tommy ....
milwak ....
jefferson ....
15letterword ....

And after 15 spaces, you wanted the next word to start. Is there a format type command that you can use, such as

printf ("%15d", int value) to get this accomplished.

Because right now, I'm traversing each string and adding a space whenever it sees a terminating character '\0'.

Is there no easier way?

Thanks,
Mistro116

Mistro116@yahoo.com 11-27-2005 02:09 PM

Edit: Nevermind, Problem Solved.

Just read the man pages and the "%-15s" command will take care of this.

Thanks anyways.
Mistro116


All times are GMT -5. The time now is 03:51 PM.