What are the format specifiers for printf when working with types such as int32_t, uint16_t and int8_t etc.?
Using% d,% i, etc. will not lead to program porting. Are PRIxx macros a better approach?
Are PRIxx macros a better approach?
As far as I know, yes.
Edit: another solution is to apply to the type that is at least the same as the one you want to print. For example, inthas a width of at least 2 bytes to print int16_twith printf("%d\n", (int)some_var).
int
int16_t
printf("%d\n", (int)some_var)
, , .
, :
#include <stdio.h> #include <stdint.h> #include <inttypes.h> int main (void) { int32_t i32 = 40000; printf ("%d\n", i32); // might work. printf ("%" PRId32 "\n", i32); // will work. return 0; }
.
, , . , 16- int .
Source: https://habr.com/ru/post/1706923/More articles:Testing dynamic pages with Google Website Optimizer - javascriptSharePoint remembers changed password - sharepointNeed a convenient WYSIWYG DotNetNuke editor - wysiwygHow do I change the "Summary view" in the SharePoint list web part? - sharepointHow are typed properties displayed in untyped DataTable in PowerShell? - powershellHow can I highlight search terms using DB2 text search in 9.5.2? - sqlaccess to objective-c exception in finally block - objective-cLinq to Entities (EF): how to get FK value without making a connection - c #Open Source Projects That Use Pex - .netWhat do people think of Gupta Team Developer? - windowsAll Articles