strange thing in VC++

simple

simple

@simple-3OHIl5 Oct 26, 2024

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?

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • samboy2005

    samboy2005

    @samboy2005-RQfItu Sep 8, 2008

    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

    @simple-3OHIl5 Sep 9, 2008

    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

    @nirajkumar-6nokRG Sep 9, 2008

    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

    @simple-3OHIl5 Sep 11, 2008

    dddd gets printed first and then aaaa and then bbbbb
    so what do you make of this??