Bookmark Topic Watch Topic
  • New Topic

Help with formatting output with Printf()  RSS feed

 
David Barry
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Report post to moderator
Good Morning, everybody. I have a program where the output is giving me trouble. I have one variable and I am wondering if I can print different parts of it on different rows. For example, I have column headers and under each header, I want to print about five values per row and I want about five rows. I am wondering if there is a way to do this? Currently all of my values are printed in one big line and I want to spit this into separate rows. Is there a way to do this? Thanks
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
You can't just expect printf() to split lines for you. To cater your output you need to do some math and explitly do println() or printf(%n) or something. Same goes for tabs or spaces in between values.

A similar easier case is how would you ensure the output to be at most 80 characters long without wrapping any words on the console?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!