'#' conversion flag in printf() doesn't work with NULL character

From: Erik Leunissen (look_at_the.footer.invalid)
Date: 02/23/05


Date: Wed, 23 Feb 2005 18:44:37 +0100

L.S.

I've observed unexpected behaviour regarding the usage of the '#' flag
in the conversion specification in the printf() family of functions. Did
I detect a bug, or is there something wrong with my expectations
regarding the effect of the following code:

     printf("NULL as hex: %#4.2x\n", '\0');

Expected output
===============

NULL as hex: 0x00

Observed output (white space is significant)
===============

NULL as hex: 00

Thanks in advance for any comments,

Erik Leunissen
==============

-- 
   leunissen@       nl | Merge the left part of these two lines into one,
e.          hccnet.   | respecting a character's position in a line.


Relevant Pages