The PRIuPTR
macro (from <inttypes.h>) defines a decimal format for uintptr_t
, which should always be large enough that you can cast a size_t
to it without truncating, e.g.
fprintf(stream, "Your size_t var has value %" PRIuPTR ".", (uintptr_t) your_var);