Peter Szinek wrote:
> Bernard Kenik wrote:
>   
>> ----- Original Message ----- From: "Peter Szinek" <peter / rubyrailways.com>
>> To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
>> Sent: Saturday, November 11, 2006 1:28 PM
>> Subject: sprintf bug (?)
>>
>>
>>     
>>> Hello all,
>>>
>>> I am wondering if I have just found a bug in (s)printf...
>>>
>>> According to the PickAxe, table "sprintf flag characters":
>>>
>>> ================= snip ==================================
>>>
>>> 0 (zero)  all  Pad with zeros, not spaces.
>>>
>>> ================= snip ==================================
>>>
>>> so I think this call
>>>
>>> irb(main):053:0> sprintf("%05s", 123)
>>> => "  123"
>>>
>>> should correctly result in
>>>
>>> "00123"
>>>
>>>       
>> sprintf("%05d",123)      # 'd' not 's'
>> => "00123"
>>     
>
> :) I know 'd' is not 's', it was a bad example. It should have been
>
> irb(main):002:0> sprintf("%10s",'hello')
> => "     hello"
>
> (there are no zeroes...)
>
> Peter
>   

Possibly you meant "%010s" instead of "%10s"? In any case, I checked the 
output of a C program compiled with gcc on my Powerbook running OS X 
10.8. In this case, the '0' flag adds padding on the left:

ruby$ cat testit.c
#include <stdio.h>

int main(int argc, char *argv[])
{
        printf("%010s", "hello\n");
        return 0;
}

ruby$ ./testit
0000hello
ruby$