Go Back  Xtreme Visual Basic Talk > General Discussion > Tech Discussions > Strange thing about a small program


Reply
 
Thread Tools Display Modes
  #1  
Old 07-08-2005, 12:44 AM
ashutosh9910's Avatar
ashutosh9910 ashutosh9910 is offline
Contributor
 
Join Date: Oct 2003
Location: Bangalore, India
Posts: 679
Default Strange thing about a small program


#include <iostream.h>
#include <stdio.h>
void main()
{
cout<<"hello";
printf("hi");

}
Output of this program is -> hihello
Anyone knows why is it so?




Ashutosh
__________________
Machine Intelligence Group, India
"A Computer once beat me in chess, but it was no match for me in kick boxing." - Emo Philips
Reply With Quote
  #2  
Old 07-08-2005, 08:54 AM
vbMike vbMike is offline
Junior Contributor
 
Join Date: Apr 2005
Posts: 258
Default

I just tested that and I'm getting hellohi
Reply With Quote
  #3  
Old 07-08-2005, 09:01 AM
CooPs's Avatar
CooPs CooPs is offline
Centurion
 
Join Date: Aug 2004
Location: Sweden
Posts: 164
Default

Someone of you two is cross-eyed
__________________
http://www.google.com/search?&q=[INSERT YOUR QUESTION HERE]
Reply With Quote
  #4  
Old 07-08-2005, 03:40 PM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,714
Default

What compiler on what operating system, what options were the libraries compiled with.
I/O (especially since I would think you shouldn't be mixing the two), can often come out in unexpected order, depending on internal buffering, and threading options.
Perhaps you have a threaded I/O library, so the cout stream is no wait I/O. The I/O is buffered in a queue to be processed by another thread, and your thread continues and you immediately send old, direct printf I/O which is not no wait, and it goes out immediately, followed
later by the cout stream which executes after your primary thread relinquishes the processor.
Could this be a multiprocessor machine where code is running on one processor, with Operating System (and I/O) running on another processor?
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #5  
Old 07-10-2005, 11:51 PM
ashutosh9910's Avatar
ashutosh9910 ashutosh9910 is offline
Contributor
 
Join Date: Oct 2003
Location: Bangalore, India
Posts: 679
Default

__________________
Machine Intelligence Group, India
"A Computer once beat me in chess, but it was no match for me in kick boxing." - Emo Philips
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->