Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 09-08-2008, 08:36 AM   #1 (permalink)
simple's Avatar
 
True Techie

Join Date: Jan 2006

Location: Earth

Posts: 171

simple

Default strange thing in VC++

Hey guys this is a simple code snippet....

#include "h1.h"

int main()
{
cout<<"\nHello \n";
printf("\nWelcome!!!");
return 0;
}

but the output i get is "Welcome" first and then "hello".

Why is welcome statement executing first?

i have included stdio.h and iostream.h in h1.h
i am running Visual studio 6.0
any suggestions?
__________________
<A HREF=http://ubanimator.com><IMG SRC=http://img182.imageshack.us/img182/5168/userbar511415cb2.gif><A>
simple is offline  
Old 09-09-2008, 01:40 AM   #2 (permalink)
Baez's Avatar
 

Join Date: Sep 2005

Location: Toronto, Canada

Posts: 5,465

Baez is a glorious beacon of lightBaez is a glorious beacon of lightBaez is a glorious beacon of lightBaez is a glorious beacon of lightBaez is a glorious beacon of light

Default Re: strange thing in VC++

That's because the compiler still thinks your cout statement is running. All output to cout and stdout is buffered. Try adding an <<endl to the end of the cout statement and see if it works.
__________________


Last edited by Baez; 09-09-2008 at 01:44 AM.
Baez is offline  
Old 09-09-2008, 03:01 PM   #3 (permalink)
simple's Avatar
 
True Techie

Join Date: Jan 2006

Location: Earth

Posts: 171

simple

Default Re: strange thing in VC++

hey dude!!! thanks for that....it worked like you said it would...
again thanks a lot!!
c ya!!
__________________
<A HREF=http://ubanimator.com><IMG SRC=http://img182.imageshack.us/img182/5168/userbar511415cb2.gif><A>
simple is offline  
Old 09-09-2008, 08:32 PM   #4 (permalink)
Baez's Avatar
 

Join Date: Sep 2005

Location: Toronto, Canada

Posts: 5,465

Baez is a glorious beacon of lightBaez is a glorious beacon of lightBaez is a glorious beacon of lightBaez is a glorious beacon of lightBaez is a glorious beacon of light

Default Re: strange thing in VC++

No problem
__________________

Baez is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange XP problem apapa Windows Operating Systems and Software 2 07-14-2008 02:30 AM
Strange audio distortion PLZ HELP! gdxtc Windows Operating Systems and Software 2 01-25-2008 02:37 AM
I'm about to take a sledge hammer to this thing Blitersety Building, Buying, or Upgrading High Performance PC Systems 25 01-18-2008 05:11 PM
Flippin thing keeps dying on me... Help! (again) small256 Building, Buying, or Upgrading High Performance PC Systems 19 05-30-2007 12:36 AM
strange black screen problem flashychap Hardware Troubleshooting 6 05-27-2007 05:59 PM