1 //printf Usage Demo2 3 //1.int Type4 intIntvalue =2;5printf"1.normal output integral type:%i\n", intvalue);//Output 26printf"2.positive direction, reserved two bits, (before number) other bits are padded with spaces: #%2i#\n", intvalue);//Output #7printf"3.negative direction, reserved two digits, after number) other bits are padded with spaces: #%-2i#\n", intvalue);//Output # # #8printf"4.two bits reserved, other bits filled with 0: #%02i#\n", intvalue);//Output #02#9 Ten intIntValue2 = at; Oneprintf"5.the two-digit number itself, the format does not change: #%02i#\n", intValue2);//Output #23# Aprintf"6.dynamic reserved bit width, other bits filled with 0: #%0*i#\n",4, intValue2);//Output #0023# - - //2.float Type (7-bit retention of valid digits) the floatFloatvalue =6.9f; -printf"7.normal output float type:%f\n", Floatvalue);//Output 6.900000 -printf"8.the formatted decimal point retains two bits, the other bits are filled with 0: #%.2f#\n", Floatvalue);//Output #6.90# - + - floatPI =3.141592653f; +printf"9.normal output floating-point type, effectively reserved 7-bit:%f\n", pi);//Output 3.141593 Aprintf"Ten.formatting retains 10 bits, and does not have an impact, the maximum significant bit is 7 bits:%.10f\n", pi);//Output 3.1415927410 at - - //3.double type (reserved valid bit is 15 bits) - DoubleDoublevalue =3.1415926531; -printf" one by one.normal output Double type:%lf\n", Doublevalue);//Output 3.141593 -printf".The format retains 10 bits, effectively retains 15 bits, and is bit-wide with 15 bits:%.10lf\n", Doublevalue);//Output 3.1415926531 in - //4.char to CharCharvalue ='a'; +printf".character output:%c\n", charvalue);//output a
1. Normal output integral type: 2 2. Positive direction, reserved two bits, (before number) other bits are filled with spaces: # 3. Negative direction, reserved two digits, after number) other bits are padded with spaces: #2 # 4. Reserve two bits, other bits to fill with 0: #02 # 5. The two-digit number itself, formatting does not change: #23 # 6. Dynamic reserved bit width: #0023 # 7. Normal output Float type: 6.900000 8. Format the decimal point to retain two bits, and the other bits to fill with 0: #6.90# 9. Normal output floating-point type, effectively reserved 7-bit: 3.141593 10. Formatting retains 10 bits, and does not have an impact, the maximum significant bit is 7 bits: 3.1415927410 11. Normal output Double type: 3.141593 12. Format reserved 10 bits, effectively reserved 15 bits, will be bit width of 15 bits: 3.1415926531 13. Character output: a |
printf Usage Demo