When you compile the following code in VS 6 you get the output as Code: #include <iostream.h> #include <stdio.h> void main() { cout<<"hello"; printf("hi"); } hihello The reason behind this is cout is not flushed and you can get the desired out put by doing Code: #include <iostream.h> #include <stdio.h> void main() { cout<<"hello"; flush(cout); printf("hi"); } You can also use the <<endl; to flush the output after each cout but keep in mind that flushing the output can degrade performance. Thanks Shabbir Bhimani
I might mention that iostream.h is deprecated and is provided for backward compatibility. One should use iostream without an extension. The phenomenon occurs because cout and printf use two different streams; they may, however, be synced. It is generally not good practice to mix the two forms.
Forgot to mention that "void main" is non-standard code. The standard specifies that main return an int. Some compilers, particularly less compliant ones, accept the void specification, but its use is non-standard and not recommended practice.
does <<endl; really flush the buffer? I seriously doubt coz putting \n in printf does not. then how can endl do that