[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Ok...I got it. :-)



mark@cheers.jsc.nasa.gov (Mark Manning/Metrica) writes:
>On the previous problem with the printf, I realized I was
>mixing my FORTRAN and Perl together.  (Man - too many
>languages running around in my head.  :-) ).  I should have
>used "%d" instead of "%i".  So let me ask this: Why did it
>produce a "1" when the "%i" was used?  Still curious.  :-)

When doing an s?printf, Perl breaks up the format string until it finds
a %-spec. %i being a Standard C extension and Perl being pre-Std C, Perl
doesn't know about %i and ends up calling sprintf(s, "%i"), which
essentially inserts an architecture dependent nonsense number into the stream.

You probably should report this bug (just run "perlbug" on your workstation).
Point out that modern C defines %i as a synonyme for %d.

Matthias

-----
Matthias Neeracher                                   neeri@iis.ethz.ch
   "These days, though, you have to be pretty technical before you can 
    even aspire to crudeness." -- William Gibson, _Johnny Mnemonic_