¿Alguien puede explicar el concepto de buffers un poco más explícitamente? Entiendo que los almacenamientos intermedios son estructuras de datos donde se almacenan los caracteres y el lugar donde se deben leer los datos. ¿Cuál es la idea de limpiar los buffers?C++ cout y cin buffers, y buffers en general
Cuando se vacía un búfer, ¿esto se refiere al acto de escribir los caracteres almacenados en él?
A partir del texto:
To avoid the overhead of writing in response to each output request, the library uses the
buffer to accumulate the characters to be written, and flushes the buffer, by writing its
contents to the output device, only when necessary. By doing so, it can combine several
output operations into a single write.
Cuando se hace referencia a 'lavado' que casi hace que suene como si el buffer está siendo escrito, sino también borra al mismo tiempo. Solo especulación.
Entonces, para que se escriba para ver en una pantalla, se requiere el lavado con buffer?
When our program writes its prompt to cout, that output goes into the buffer associated
with the standard output stream. Next, we attempt to read from cin. This read flushes
the cout buffer, so we are assured that our user will see the prompt.
Aquí, suena como si el mediante el uso de 'endl' al final le dice al sistema que necesita para escribir inmediatamente (lo que implica que no es otra cosa?) Lo que no se usa endl?
Writing the value of std::endl ends the line of
output, and then flushes the buffer, which forces the system to write to the output
stream immediately.
esta pregunta ha sido formulada y respondida durante mucho tiempo en SO. http://stackoverflow.com/a/4752069/1155650 –