![d1ffc832a7694c8e9ada9bcdc4856c24.png](https://img-blog.csdnimg.cn/img_convert/d1ffc832a7694c8e9ada9bcdc4856c24.png)
C++中 printf 与 cout 的本质区别在于:
- printf 是函数;
- std::cout 是全局对象,operator << 是流运算符, std::cout 重载了 << 运算符。
两者的官方定义如下。
printf
Loads the data from the given locations, converts them to character string equivalents and writes the results to a variety of sinks.
std::cout
The global objects std::cout control output to a stream buffer of implementation-defined type (derived from std::streambuf), associated with the standard C output stream stdout.
printf 常用的输出控制符:
![6dd018e57557064b509997a2240d2178.png](https://img-blog.csdnimg.cn/img_convert/6dd018e57557064b509997a2240d2178.png)