CrazyEngineers
  • simple
    simple

    MemberSep 8, 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?
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • samboy2005

    MemberSep 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 .
    Are you sure? This action cannot be undone.
    Cancel
  • simple

    MemberSep 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!!
    Are you sure? This action cannot be undone.
    Cancel
  • niraj.kumar

    MemberSep 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??
    Are you sure? This action cannot be undone.
    Cancel
  • simple

    MemberSep 11, 2008

    dddd gets printed first and then aaaa and then bbbbb
    so what do you make of this??
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register