delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/25/17:31:36

From: Jason Green <news AT jgreen4 DOT fsnet DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Weird output of printf()
Date: Tue, 25 Jan 2000 22:05:40 +0000
Organization: Customer of Planet Online
Lines: 16
Message-ID: <517s8s44q97grjfra88cqj2ur7pj0f6bjm@4ax.com>
References: <388B549C DOT A2C038D AT ou DOT edu> <Pine DOT SUN DOT 3 DOT 91 DOT 1000124092228 DOT 10104F AT is> <e8ip8s8u3pqm4qv1k5m9f42t408l8f372g AT 4ax DOT com> <86jqbc$49u$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE>
NNTP-Posting-Host: modem-19.hyalgan.dialup.pol.co.uk
Mime-Version: 1.0
X-Trace: news5.svr.pol.co.uk 948838315 19402 62.136.71.19 (25 Jan 2000 22:11:55 GMT)
NNTP-Posting-Date: 25 Jan 2000 22:11:55 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Newsreader: Forte Agent 1.7/32.534
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hans-Bernhard Broeker <broeker AT acp3bf DOT physik DOT rwth-aachen DOT de> wrote:

> > If it should work then I would expect "%#02x" to be the required
> 
> Make that "%#04x", and it'll work. The '2' is too small, as it has to
> count total output field width, including the "0x" added by that '#'
> option in the format.

Aha! Quite obvious really. :-)

> Alternatively, you could 
> 
> 	printf("0x%02x\n", 0x0f);
> 
> Same result, easier to understand.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019