HP OpenVMS Systems

ask the wizard
Content starts here

long long (__int64) printf conversion?

» close window

The Question is:

In Compaq C 6.5-001 I want to print an unsigned __int64 value using printf.
Using format specifier %lu I get a compiler warning '%CC-W-OUTTYPELEN, In this
 statement, this argument to fprintf is of "an unsigned integer 64" type and is
 not appropriate for the conversion specifier "%lu".  The value might be
 truncated or formatted in
 an unintended manner.' In Compaq C 6.0-001 there is no warning message but
 values larger than 32 bits are truncated.
How can I format and print a number between 4294967296 and 18446744073709551615?

The Answer is :

  For an __int64 (long long) value, the proper conversion specification
  flags are 'll' and 'L', and not 'l'.  Also see 'u' for unsigned values.
  This material is documented in the C RTL Reference Manual, in the
  section on available conversion specifiers.  (If you have not had the
  opportunity to read the C documentation in recent times, please do make
  the effort -- there have been substantial changes to the manuals that
  correspond to the enhancements made to the recent compiler releases.)

answer written or last revised on ( 3-JUN-2003 )

» close window