From: Gennady Date: 2004-04-22T03:35:46+09:00 Subject: Re: printf / indent Gennady wrote: > Its Me wrote: > >> Shouldn't sprintf truncate strings if needed? >> >> sprintf("%10s", "Hello") --> " Hello": correct padding >> sprintf("%3s", "Hello") --> "Hello": no truncation? > > > If you need truncation you should use > sprintf("%3.3s,"Hello") Correction: sprintf("%3.3s","Hello") (missed the quote) > > The precision field for strings in C printf (and in Ruby's consequently) > is just that -- specifies the maximum size of a filed. > > Gennady. > >> >> Bug? Operator error? >> >> "Its Me" wrote in message >> news:cuyhc.9568$hR1.4441@fe2.texas.rr.com... >> >>> How can I control starting (left) indentation for printf? Pickaxe did >>> not >>> yield an answer. Or do I have to loop putting out spaces with >>> IO#putc " "? >>> >>> Thanks! >>> >>> >> >> >> >> > >