Re: sprintf(): different output on Windows and Linux

new topic     » goto parent     » topic index » view thread      » older message » newer message

Julio C. Galaret Viera wrote:
> 
> Robert Craig wrote:
> > 
> > Julio C. Galaret Viera wrote:
> > > sprintf("%03s", {"62"})
> > > 
> > > on Windows: "062"
> > > on Linux:   " 62" (a blank space instead of zero)
> > > 
> > > Why? It's supposed to produce the same output on both, isn't it?
> > 
> > The "leading zeros" feature of printf/sprintf is really meant
> > for numeric data, not strings, so I guess the C printf() library
> > routines that Euphoria depends on, are not compatible in 
> > this unusual case.
> > 
> > If you do:
> >    sprintf("%03d", 62)
> > they both give:
> >    "062"
> > 
> > Regards,
> >    Rob Craig
> >    Rapid Deployment Software
> >    <a href="http://www.RapidEuphoria.com">http://www.RapidEuphoria.com</a>
> 
> Yes, I'm aware of being meant for numeric data. I'm using the function to
> create
> name files from strings (not numbers) that when displayed with dir/ls commands
> are listed alphabetically (004, 011, 032, and not 11, 32, 4) and when I tried
> on Linux they appeared as "\  0", "\  1", "\  2", etc.
> 
> It doesn't really matter since I can convert the strings to numeric format
> before
> passing them to sprintf() function, but I want to know what it may be caused
> by.
> 
> Thanks.
> 
> JG

Hi there,

That's very interesting and maybe good you brought this up.
For my own purposes, i'm pretty sure i always use
  sprintf("%s", {"62"})
or something like that, with no numbers before the 's'.



Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

 From "Black Knight":
"I can live with losing the good fight,
 but i can not live without fighting it".
"Well on second thought, maybe not."

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu