simple
simple
Branch Unspecified
12 Sep 2008

strange thing in VC++

i wrote the following code snippet in Visual C++ 6.0
#include "h1.h"
int main()
{
cout<<"\nHello \n";
printf("\nWelcome!!!");
return 0;
}
strange thing is that "welcome" gets displayed first and "hello" thereafter....
why is "welcome" getting executed first??

i have included stdio.h and iostream.h in h1.h.
any suggestions?
samboy2005

samboy2005

Branch Unspecified
10 years ago
i think printf command has higher priority then cout .....
haven't been in touch for long time with VC++..not very sure .but think this might be the case .
simple

simple

Branch Unspecified
10 years ago
no i guess i found the answer
cout is buffered, so if i add an endl at the end of cout it works perfectly fine!!
any other reply is still welcome!!
thanks n c ya!!
niraj.kumar

niraj.kumar

Branch Unspecified
10 years ago
I dont know the answer but I am not convinced with your answer the reason is that if YOU HAVE

cout<<"Aaaaa";
printf("ddddd");
count<<"bbbbb";

so in this case Aaaaa and bbbb would print sep??
simple

simple

Branch Unspecified
10 years ago
dddd gets printed first and then aaaa and then bbbbb
so what do you make of this??

Share this content on your social channels -

Only logged in users can reply.