2

In Linux I need to sprintf uint64_t This is how it defined in "stdint.h"

typedef unsigned long int   uint64_t;

What should i pass to sprintf?

Oleg Vazhnev
  • 22,231
  • 49
  • 161
  • 290

1 Answers1

2

The header <inttypes.h> defines macros to be used with the *printf and *scanf functions for the types defined in <stdint.h>.

To format a uint64_t value in decimal:

uint64_t n = ...;
sprintf(str, "%" PRIu64, n);

The PRIu64 macro expands to a string literal, which is concatenated with the "%" to form a valid format string.

Keith Thompson
  • 242,098
  • 41
  • 402
  • 602