Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Stream vs Buffer

Reply
Thread Tools

Stream vs Buffer

 
 
Sandy
Guest
Posts: n/a
 
      07-23-2005
Hi,
In one of my interview i was asked the difference between Stream and Buffer.
can anybody explain the difference.

Thanks


 
Reply With Quote
 
 
 
 
Maxim Yegorushkin
Guest
Posts: n/a
 
      07-23-2005
On Sat, 23 Jul 2005 14:06:07 +0400, Sandy <(E-Mail Removed)> wrote:

> Hi,
> In one of my interview i was asked the difference between Stream and
> Buffer.
> can anybody explain the difference.


Standard streams are just mere formatters. They use streambufffers to do
actual IO.

--
Maxim Yegorushkin
<(E-Mail Removed)>
 
Reply With Quote
 
 
 
 
Steven T. Hatton
Guest
Posts: n/a
 
      07-23-2005
Maxim Yegorushkin wrote:

> On Sat, 23 Jul 2005 14:06:07 +0400, Sandy <(E-Mail Removed)> wrote:
>
>> Hi,
>> In one of my interview i was asked the difference between Stream and
>> Buffer.
>> can anybody explain the difference.

>
> Standard streams are just mere formatters. They use streambufffers to do
> actual IO.
>

As I understand things (and that may not be well), the default iostream has
a buffer capacity of 1, and therefore isn't really a buffer at all.
Perhaps Dietmar can clear this up?
--
If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true.-Bertrand Russell
 
Reply With Quote
 
Steven T. Hatton
Guest
Posts: n/a
 
      07-23-2005
Steven T. Hatton wrote:

> Maxim Yegorushkin wrote:
>
>> On Sat, 23 Jul 2005 14:06:07 +0400, Sandy <(E-Mail Removed)> wrote:
>>
>>> Hi,
>>> In one of my interview i was asked the difference between Stream and
>>> Buffer.
>>> can anybody explain the difference.

>>
>> Standard streams are just mere formatters. They use streambufffers to do
>> actual IO.
>>

> As I understand things (and that may not be well), the default iostream
> has a buffer capacity of 1, and therefore isn't really a buffer at all.
> Perhaps Dietmar can clear this up?



Whoops! I meant to say 'isn't really buffered at all'.
--
If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true.-Bertrand Russell
 
Reply With Quote
 
Maxim Yegorushkin
Guest
Posts: n/a
 
      07-23-2005
On Sat, 23 Jul 2005 15:12:36 +0400, Steven T. Hatton
<(E-Mail Removed)> wrote:

> As I understand things (and that may not be well), the default iostream
> has a buffer capacity of 1, and therefore isn't really a buffer at all.


I'm interested why would you care?

--
Maxim Yegorushkin
<(E-Mail Removed)>
 
Reply With Quote
 
Dietmar Kuehl
Guest
Posts: n/a
 
      07-24-2005
Steven T. Hatton wrote:
> As I understand things (and that may not be well), the default iostream
> has a buffer capacity of 1, and therefore isn't really a buffer at all.
> Perhaps Dietmar can clear this up?


What is a "default iostream"? There are eight standard stream objects
(cin, cout, cerr, clog and their wide character counterparts). The
standard does not state whether these are buffered or not. Essentially,
whether they are buffered on stream buffer level normally depends on
the implementation strategy with respect to the standard C stream
(stdin, stdout, and stderr): by default, the C and C++ streams are
in some form synchronized, i.e. you can mix input and output of the
C and C++ streams and the character sequences are still in the order
the output was done. To achieve this, the C++ stream buffers are
either unbuffered and use the standard interface of the C streams
internally or the C++ stream buffers somehow share their buffer with
the corresponding C streams. The latter generally only works if the
implementation controls both the C and the C++ implementation. In
any case, on the C level the streams are typically always buffered
unless the C stream is setup explicity be unbuffered.

For all other IOStreams in the standard C++ library, e.g. file and
string streams, it is safe to assume that they are buffered. Whether
user-defined streams are buffered or not depends on the implementation
of the corresponding stream buffer but obviously the C++ standard does
not make any statement here. That is, in summary most stream buffers
are likely to be buffered but the standard does not guarantee anything
in this area. Of course, I'd recommend that all stream buffers should
do actual buffering because this can be used by many algorithms in the
standard C++ library: these can be specialized to cope with stream
buffers specially and e.g. bypass the stream buffer interface in many
interesting situations.
--
<(E-Mail Removed)> <http://www.dietmar-kuehl.de/>
<http://www.eai-systems.com> - Efficient Artificial Intelligence
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
buffer creates only read-only buffer? Neal Becker Python 0 01-08-2009 01:58 AM
When using System.IO.FileStream, I write 8 bytes, then seek to the start of the file, does the 8 bytes get flushed on seek and the buffer become a readbuffer at that point instead of being a write buffer? DR ASP .Net 2 07-29-2008 09:50 AM
When using System.IO.FileStream, I write 8 bytes, then seek to the start of the file, does the 8 bytes get flushed on seek and the buffer become a readbuffer at that point instead of being a write buffer? DR ASP .Net Building Controls 0 07-29-2008 01:37 AM
convert M bit buffer to N bit buffer runcyclexcski@yahoo.com C++ 2 03-26-2007 09:43 AM
How to know the buffer size and increase buffer size in c++ Raja C++ 12 06-21-2004 06:21 PM



Advertisments