Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printf with Hexadecimal

Status
Not open for further replies.

Denyson

Programmer
Mar 20, 2001
19
BR
Hi,

I'm using printf to show a Hexadecimal Number like this:

printf("%X",pbAttr); where pbAttr is a PUCHAR[32]

But the problem is that I also want to show the left zeros in the Hexadecimal Number. For exemplo:

If I have 0x0000FFGG, the printf show only FFGG.

Could anybody help me?
 
Try:
[tt]
printf("%08X",pbAttr);
[/tt]

The '0' means to prefix with zeros, and the '8' means to use a minimum of eight places to show the number.

Chip H.

 
Hi Denyson,

If you want the left zeros to be printed also,
try this.

printf("0x%08X\n", pbAttr);
This will print 0x0000FFGG instead of FFGG.
Btw did u mean FFGG or FFCC ?

abp :cool:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top