DEV Community

Discussion on: C++ Hello World

 
theplebdev profile image
Tristan Elliott

ok, Awesome. Can you explain the concept of a buffer to me? I have read a little about it when dealing with streams in java but I still can't wrap my head around it.

Thread Thread
 
thefluxapex profile image
Ian Pride • Edited

Well, I won't get deep into it, but it's sort of just like a buffer for video when you watch anything that streams to you, it is the place that stores the data before it is displayed, with video it's video data (still just data as far as a machine is concerned), here we are speaking about string or character data (text, from cout, to cin etc...).

In video data if the content didn't come to you and be stored in the buffer first it would continuously stutter showing one or few frames at a time before it had to download the next set of frames. The buffer here is what is put into cout in the stream and unless you send a newline (in most cases, but not always automatically flushing) or flush the buffer, it may not display when you want it to. It really depends on a variety of things mostly depending on what you're doing.

There is more to it than this, of course.

So TLDR;

It is the place where the string or character data for a stream is stored before it is displayed; buffering the data.

Thread Thread
 
theplebdev profile image
Tristan Elliott

Ok, that actually helps a lot. Thank you again. You have been a huge help!