请看以下示例:
#include <stdio.h> #include <iostream> int main() { std::cout << "Hello "; printf("beautiful "); std::cout << "world!"; printf("\n"); }
使用同步时,程序自行打印在一行中
Hello beautiful world! :
不使用同步时,输出会变得杂乱。