Skip to content
loading...

printf format for a system dependent number type

github logo ・1 min read  

#c

It’s not that easy to get printf (3) format right. Especially with datatypes such as size_t or other *_ts – which size depends on the system architecture.
You may need to resort to #include <inttypes.h> and PRI macros defined there.

For example:

#include <inttypes.h>
uint32_t val;
printf("val is: %"PRIu32", unsigned 32 bit", val)
twitter logo DISCUSS
Classic DEV Post from Jul 20 '19

What Makes You a Great Programmer on The Team?

Majority of software developers are aspired to be not only a competent professional but also a great one.

Tomasz Sterna profile image
I am a coder. I do hard-core C, Embedded JavaScript, C++/Qt/QML, Rust GameDev, Reason React, XMPP. Preferably Open Source.