"Lionel B" <me@privacy.net> wrote in message
news:42cce599$0$18643$14726298@news.sunsite.dk...
[color=blue]
> Sharad Kala wrote:[color=green]
>> "Ashish Sharma" <Neo.Scorpio@gmail.com> wrote in message
>>[color=darkred]
>>> #include <iostream.h>[/color]
>>
>> Non-standard header. Check the archive and you will see umpteen
>> discussions on it.
>>[color=darkred]
>>> #include <stdio.h>
>>> void main()[/color]
>>
>> int main. Again check the archive.
>>[color=darkred]
>>> {
>>> cout<<"hello";
>>> printf("hi");
>>>
>>> }
>>>
>>>
>>> its coming out like
>>>
>>> hihello[/color]
>>
>> No wonder. Buffering of output stream is causing the surpises for
>> you. C and C++ standard streams need to be kept in sync when both
>> libraries' facilities are in use
>> -- check std::ios::sync_with_stdio.[/color]
>
> Out of interest, is there (or perhaps should there be) a standard on
> whether the C and C++ standard streams are synched by default? Looking
> back at some old code, I find I've often used:
>
> std::ios::sync_with_stdio(false);
>
> when using just the C++ standard streams, so as to avoid the I/O
> performance hit incurred by synching. I think gcc (as of ver 3.0) does
> synch by default; see:
>
>
http://gcc.gnu.org/onlinedocs/libstd...o/howto.html#8[/color]
The C++ Standard requires that the standard streams be synchronized
by default. You might feel moved to turn it off, in the hopes of
improving performance, but you don't have to turn it on anymore
with sync_with_stdio. Our library has no performance penalty for
synchronizing streams.
P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com