   Having trouble understanding how i/o streams work
  I just today started reading accelerated C++ and I got to the working with strings chapter and I find his description of streams and buffers confusing . Could somebody explain how the process works or something.   
  You're more likely to get help if you point specifically to sentences and points you don't understand. As of now, your question translates to "I can't understand a book, so teach me yourself".If we don't know what confuses you, we can't help you specifically.   ;  Sorry but I wasn't asking you to explain the entire book. What I meant was the part when he explains input and output streams and buffers confuses me. Can somebody explain how these these things work when it comes to handling text.   ;  What, exactly, do you find confusing about them? It's difficult to help you if you don't ask specific questions.   ;  http://www.cplusplus.com/reference/string/string/  Maybe that can be of some help to you.  There's several different resources available online that you may find useful other than the one provided.  I read an awful lot, so if I don't quite understand something from one person I immediately jump onto Google and see what I can find someone elses point of view.  Be careful though, if this becomes a habit you may find yourself jumping from subject to subject and forget where you started. :)   ;  I google'd "iostream tutorial" and this first link seemed decent to start:http://www.cplusplus.com/doc/tutorial/files/if not, continue looking for more.The fine art of selecting good simple google criteria (and then filtering results quickly) will serve you well, practice it.   ;  My understanding is they work like an actual stream (runnig water). Think of reading a file, the file is a lake and it pours down the stream, you read from the bottom of that stream. Same for console input,, it too goes down a stream where you can read it from the bottom. Eventually it might run out (expecially if its a file read).You can either read one bit at a time from the bottom or you can read a big chunk (starting from the bottom). You need somewhere to put what you read and that thing is a buffer. A buffer is usually just an array of bytes/chars, think of it as a bucket and instead of reading one bit of the stream at a time you fill the whole bucket and can examine it as you wish. You can use a small bucket, a big bucket and these might not be filled (no more water left). There is probably also buffers in the streams but I don't rally know.When writting to a stream I believe the stream buffers what you send in and then writes it to the desired location (if there is one). Again, think of writting to a file, the hard drive can only write data at a limitted speed (with of the stream say). When you tell it to write your effectivly pouring water into a lake (the buffer) and it slowly trickles down the stream from the lake to the destination (file).You can also have streams (stringstream for example) where you might be pouring in the top and collecting at the bottom (useful method of formatting strings).I hope that was of some use, you can use streams without understanding them, I don't remember understanding them when I first started c++. If you needed to understand everyhting before you used it we'de never get anywhere.   ;  I've seen the stream/river analogy before, as well as a conveyor belt to or from a distribution warehouse or raw materials receiving center at a factory.  A big advantage of streams is that you don't have to know the details about how the data acquisition or output mechanisms of your hardware and operating system work to use them.  How the water gets into the lake and into your stream or how the car is taken off the conveyor belt at your distribution warehouse and what happens after it is loaded on a trailer headed to the car dealer is already taken care of for you.In the case of C++, how we use a stream is defined by the member functions of its stream class, in the same way as an automobile class might have an Accelerate() method or an airplane class might have a TakeOff() method.  Using our factory analogy, in order to use a stream, we have to have a conveyor belt object, just as we would need an automobile object to Accelerate() or a plane object to TakeOff().  The most common way we use our conveyor belt or stream is to put something on/in it or take something off/from it.  We often do that in C++ using the << and >> operators.The conveyor belts between our factory and our usual distribution warehouse and raw materials receiving center have already been defined for us.  They are cout and cin. Sometimes we will want to send our product somewhere other than our distribution warehouse or bring in materials from somewhere other than our raw materials receiving center.  (ETA: or, if we're Toyota, maybe we have to recall our cars, test them, fix some things, and send them back out to our dealers or customers).  In those cases, we will need another conveyor belt to move those things, so we will have to create our own stream objects using C++'s stream classes.  We can create an fstream (file stream) object, for example, that lets us read and write to a file.A buffer is a temporary storage place for data.  In the case of our factory, we might not use our raw materials right from the conveyor belt.  Instead, maybe they are stored in bins on the factory floor before being fed into our machinery.  In fact, there can be buffers on both ends of the the conveyor belt.  Thankfully we don't usually (ETA:as beginning programmers) have to worry about what's going on in the distribution warehouse or how the cars get to the car dealer, but the warehouse itself is a kind of buffer.  In fact, if you've ever used cout << endl you've put a message on your cout conveyor belt to move to a new line on the screen and clear out the distribution warehouse immediately.[Edited by - Crowseye on June 7, 2010 10:24:36 AM]