C++?stdio
????????????????,?printf
?fprintf
?????????????????????????????????????:
-
???????:
%d
:??(int)%ld
:???(long int)%lld
:????(long long int)\u
:?????(unsigned int)%lu
:??????(unsigned long int)%llu
:???????(unsigned long long int)%f
:???(float)%lf
:??????(double)%Lf
:???????(long double)%c
:??(char)%s
:???(const char*)%p
:??(void*)
-
?????:
-
:???+
:?????0
:?????#
:????????????????
:????????
-
?????:
- ??:?????????,????????????:
]
,???????????5,????????? - ??:???????????????:
%.2f
,?????,???????
- ??:?????????,????????????:
-
????:
??????????????????,?????????????????:
#include
#include int main() { int num = 42; float pi = 3.14159; printf("Number: %-5d, Pi: %.2f\n", num, pi); printf("Number: d, Pi: %#.2f\n", num, pi); printf("Number: %+5d, Pi: % .2f\n", num, pi); return 0; } ????:
Number: 42 , Pi: 3.14 Number: 00042, Pi: 3.14 Number: +42 , Pi: 3.14
?????????????,?????????C++?????????