4 ms·
Imagine you just called time(2) and got a time_t value. Something like: time_t asdf = time(); And now you want to use printf to print that value to the sc
by dmm 13y ago
Imagine you just called time(2) and got a time_t value. Something like:
time_t asdf = time();
And now you want to use printf to print that value to the screen. You can cast to 'long long', which is guaranteed to be at at least 64 bits wide, and ensure no loss of precision occurs:
printf("%lld", (long long)asdf);
That will work whether time_t is 32 bit or 64 bit.
- Peaker 13y agoIf they just added a macro to inttypes.h, you could use that for the format specifier. If you want to print a uint32_t, you just use PRIu32.