what is buffer

actually what is buffer why the values will be stored in buffer during programming

What is buffer

A buffer is a space in memory where data is stored temporarily. Lets say you open a file. If you read from that file, you might want to read one BYTE at a time. This would be slow.

So you decide to read one LINE at a time. So in C++ you might do this:

char buffer[256];
FILE *input_file;

fgets(buffer, 256, input_file);

Which would read 256 characters from “input_file” and store then in the
in the character string “buffer”.
A buffer is basicly an array where you place data before or after processing it.

Why is it used

Information sent from one application to another cannot always be transferred instantly. The receiving program may be busy, and waiting for it to respond to a request would cause the calling program to hang. Programs that regularly communicate with each other establish a “pipeline,” which is a buffer for commands. In this case the buffer is a file. The calling program sends the request down the pipeline, writes data to the file and then gets on with other tasks, periodically checking a different buffer to see whether the other program has fulfilled the request and written out the results.
Therefore, hanging or slowing of the program can be avoided.

Read more here: Wikipedia

4 Likes

Hi,

Please follow below link for C Language tutorial and questions

link text

//