?C++?,printf
????C?????????????????????????????:
#include// ?? #include int main() { int a = 10; float b = 3.14; const char* s = "Hello, World!"; printf("??: %d\n", a); printf("???: %.2f\n", b); printf("???: %s\n", s); return 0; }
??????,????printf
??????????????????????%d
?%.2f
?%s
??????,????printf
???????????????????
?????????????:
%d
:??(int)%f
:???(float/double)%s
:???(const char*)%c
:??(char)%x
:??????(int)%o
:?????(int)%%
:?????(%)
????????????????,??:
]
:??????,??5?????,??????????d
:??????,??5?????,?????0???%6.2f
:???????,??6?????,??2???,??????????
??:?C++?,?????std::cout
????,???????????????????printf
???C++?????,??????C?????????????????