size_t s = 1; printf("%Iu", s);If you are developing a Linux-application, you may use the size specifier "z". For example:
ptrdiff_t s = 1; printf("%zd", s);Specifiers are well described in the Wikipedia article "printf".
If you have to maintain the code being ported that supports functions like sscanf, you may use special macros opening into the necessary size specifiers in the format of the command strings. Here is an example of a macro that helps you create ported code for various systems:
// PR_SIZET on Win64 = "I" // PR_SIZET on Win32 = "" // PR_SIZET on Linux64 = "z" // ... size_t u; scanf("%" PR_SIZET "u", &u); printf("%" PR_SIZET "x", u);
Комментариев нет:
Отправить комментарий