printf("A\n");
cout<<"B\n";
printf("C\n");
the ouput is :
A
C
B
not:
A
B
C
why?
answer:
you shouldn't mix "printf()" and "cout" in the same program because C stdio and C++ iostreams are completely independent and they may have different buffering scheme and they
don't share the same buffer, so the ouput may come out in an order that you are not expecting, that is probably what happened in your case.
本文探讨了在一个程序中同时使用C语言的printf()和C++的cout导致输出顺序混乱的问题。解释了C标准输入输出与C++ iostream之间的独立缓冲机制,并给出了解决方案。
1万+





