Re: printf unsigned long long as hex



Schraalhans Keukenmeester wrote, On 01/07/07 19:08:
Hi,

printf's format specifier %X only prints values of up to 8 hex digits.

Then presumably that is the number of digits required to represent an unsigned int on your implemention.

I am using GCC on Gentoo Linux. (How do I find which GCC version I have?)

The correct place to ask that is your man/info pages of gnu.gcc.help, but I'm feeling generous, so I suggest you try 'gcc -v'.

Is it possible to print values as hex up to 15 or 16 hex digits? If not,
a workaround would be appreciated also.

Use the correct format specifier for the type you are printing. 'man 3 printf' or your textbook will give you lots of information (if you don't have a textbook I strongly suggest buying K&R2 (search the group for full details), but depending on the details yout might want %lX or %llX, but note that the value you pass should be of type unsigned whatever.
--
Flash Gordon
.



Relevant Pages

  • Re: use of %
    ... of functions interpret it as a format specifier; ... textbook can tell you all about format specifiers. ... "%%" is a special format specifier denoting a literal '%'. ...
    (comp.lang.c)
  • printf unsigned long long as hex
    ... printf's format specifier %X only prints values of up to 8 hex digits. ... I am using GCC on Gentoo Linux. ...
    (comp.lang.c)
  • Re: printf unsigned long long as hex
    ... printf's format specifier %X only prints values of up to 8 hex digits. ... I am using GCC on Gentoo Linux. ...
    (comp.lang.c)
  • Re: printf unsigned long long as hex
    ... printf's format specifier %X only prints values of up to 8 hex digits. ... I am using GCC on Gentoo Linux. ...
    (comp.lang.c)