C/C++ - Printf - ShareTechnote
C/C++ | |||
printf() As you know from "Hello World" program, you would know that printf() is a function to print out anything that you specified. It is very simple to use, but we often get confused by what kind of format we have to specify in order to get the right format that we want to get. The syntax is as simple as follows. int printf(const char *format, ...); I would look very simple.. but you will see a long list of descriptions about '*format', but just reading throught the document would not help you much. I think the bunch of examples without much explanation would be bettern than long dry writing.
Result :------------------------------------ printf("%d",d) ==>123 printf("%8d",d) ==> 123 printf("%08d",d) ==>00000123 printf("%x",d) ==>7b printf("0x%x",d) ==>0x7b printf("%#x",d) ==>0x7b printf("0x%8x",d) ==>0x 7b printf("%#10x",d) ==> 0x7b printf("0x%08x",d) ==>0x0000007b printf("%#010x",d) ==>0x0000007b printf("%#X",d) ==>0X7B printf("0x%8X",d) ==>0x 7B printf("%#10X",d) ==> 0X7B printf("0X%08X",d) ==>0X0000007B printf("%#010X",d) ==>0X0000007B printf("%f",f) ==>123.449997 printf("%8.2f",f) ==> 123.45 printf("%08.2f",f) ==>00123.45 printf("%8.3f",f) ==> 123.450 printf("%08.3f",f) ==>0123.450
Result :------------------------------------ xLong in (%d) = 2147483647 xLong in (%ld) = 2147483647 xLongLong in (%d) = -1 xLongLong in (%ld) = -1 xLongLong in (%lld) = 9223372036854775807
Result :------------------------------------ xDouble in (%f) = 2147483647.000000 xDouble in (%e) = 2.147484e+009 xDouble in (%E) = 2.147484E+009 xDouble in (%g) = 2.14748e+009 xDouble in (%G) = 2.14748E+009 There is no printf option or any other functions to print a number in a binary format. So you need to create such a function on your own. Refer to Printing in a Binary Format example. |
Từ khóa » C 0x 08x
-
What Is The Difference Between %p And 0x%08x - Stack Overflow
-
%#08x Formatting Of Printf - C / C++ - Bytes Developer Community
-
"0x%08x" C语言- Echo111333 - 博客园
-
C语言问题:0x%08x表示什么 - 百度知道
-
%#08x Formatting Of Printf | C Programming | Coding Forums
-
Error At 0x%08X - C Board
-
关于printf输出格式%#08x的解释 - CSDN博客
-
"0x%08x" C语言_weixin_30404405的博客
-
11921 Rssd Exited Due To An Exception. Exception Code = 0x%08X ...
-
False Positive "ImplicitDefaultLocale" In rmat("0x%08X")
-
Program
-
Sample.c