[comp.bugs.2bsd] %x vs. %X vs %lx

scs@adam.pika.mit.edu (Steve Summit) (07/29/89)

In article <34005@wlbr.IMSD.CONTEL.COM> sms@wlv.imsd.contel.com (Steven M. Schultz) writes:
>	In porting NTPD and friends I uncovered a number of
>	problems, all related to being on a machine where
>	sizeof (int) != sizeof (long).  Using %X to print
>	the value of ntohs()...

The old code was doubly wrong; %X shouldn't be used to print a
long.  %X, %D, %U, and %O no longer imply a long argument; long
arguments are uniquely indicated with the 'l' modifier: %lx,
%ld, %lu, and %lo.  %X now means "hexadecimal, but use ABCDEF
instead of abcdef."  The other three are undefined.  (The code
presumably worked to print the long result of ntohs() on a
machine with sizeof(int) == sizeof(long).)

                                            Steve Summit
                                            scs@adam.pika.mit.edu