LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-27-2005, 02:54 PM   #1
Mistro116@yahoo.com
Member
 
Registered: Sep 2005
Posts: 118

Rep: Reputation: 15
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
 
Old 11-27-2005, 03:09 PM   #2
Mistro116@yahoo.com
Member
 
Registered: Sep 2005
Posts: 118

Original Poster
Rep: Reputation: 15
Edit: Nevermind, Problem Solved.

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

Thanks anyways.
Mistro116
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick 'n' easy question! orange400 Linux - General 6 09-09-2004 11:36 PM
Quick Question....Easy Answer iammike Linux - Software 2 08-22-2004 02:09 PM
Really quick and easy question libranikki Linux - Newbie 2 08-05-2004 08:54 PM
quick easy question alexr186 Linux - Networking 3 11-02-2003 09:48 AM
Quick Easy Basic Question RaheimSG Linux - Hardware 5 09-12-2002 08:00 AM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration