473,386 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

what is the difference between unbuffered and buffered stream??

what is the difference between unbuffered and buffered stream??
Aug 11 '09 #1
6 10775
RedSon
5,000 Expert 4TB
buffered streams store data in a buffer before and during access. unbuffered streams do not.
Aug 11 '09 #2
donbock
2,426 Expert 2GB
When you read from a buffered stream you actually read from an input buffer created and managed by the library. Characters move from the input stream to the input buffer by magic.

When you write to a buffered stream you actually write to an output buffer created and managed by the library. Characters move from the output buffer to the output stream by magic.

By magic, I mean some mechanism that is at least partially implementation-specific.

Buffering a stream can improve the overall efficiency of the application program; but at the cost of making it less certain when the real I/O operation takes place.
Aug 11 '09 #3
RedSon
5,000 Expert 4TB
Also, we should mention here that when writing or reading from an unbuffered stream you have a chance that no one will be there to take the data you have written or that there will be data there for you to read.
Aug 11 '09 #4
thank u donbock and redson but the point is still not clear,,how can we choose between a buffered and unbuffered stream??and what is the main advantage of a buffered stream??? we say that cerr uses unbuffered stream and cout use buffered but i am unable to get the logic behind it.
reply shall be appreciated.
thanx.
Aug 12 '09 #5
donbock
2,426 Expert 2GB
@zeeshan708
Are you asking about the standard streams (cin, cout, cerr, clog); or are you concerned with some other stream?

Are you asking for the mechanics of how to coerce a stream to be buffered/unbuffered; or are you asking the more abstract question of why do buffered/unbuffered I/O exist?

Why don't you start off by explaining to us what you understand about buffered vs unbuffered I/O?
Aug 12 '09 #6
I am asking about the standard streams,,,,what i think is that may be in buffered stream the data first comes into some registers and then as the registers get full the data is sent out and in case of unbuffered data goes directly,,but thats just a ruff idea in my mind,,i want a clear answer, thanx alot
Aug 12 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Alligator | last post by:
And more specifically what is the difference between an InputStream and a BufferedInputStream? When should I use one and when should I use the other? And why is there besides a...
5
by: Rich | last post by:
Does anyone know the correct way of opening an unbuffered output file using STL? I attempted: ofstream myfile("fname.txt", ios::binary); myfile.setbuf(NULL, 0); and I was informed that...
16
by: Quick Function | last post by:
What does it mean: int (*a);
0
by: | last post by:
I was hoping that someone (after my own failures) might post a very mininal unbuffered derivation of basic_streambuf. My problem is that (even leaving the buffer pointers to their defaults) uflow()...
1
by: | last post by:
Is this even possible? I've found some references to specific "unbuffered" type methods that exist in older incarnations of basic_streambuf but not in newer ones. Info please. :P
23
by: herrcho | last post by:
What's the difference between STDIN and Keyboard buffer ? when i get char through scanf, i type in some characters and press enter, then, where do the characters go ? to STDIN or Keyboard...
19
by: Lee Crabtree | last post by:
Is there a class in the framework that allows me read text from a file in an unbuffered manner? That is, I'd like to be able to read lines in the same manner as StreamReader.ReadLine(), but I also...
7
by: Cell | last post by:
when both are connected to screen and the anything written to these two constant file pointers will go onto the screen ?
1
by: geanyee | last post by:
In WCF, there are two modes , Stream and Buffered modes , but I don't know these difference,have anyone tell me?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.