Annotation of coherent/a/usr/man/ALL/buffer, revision 1.1.1.1

1.1       root        1: 
                      2: 
                      3: buffer                      Definition                     buffer
                      4: 
                      5: 
                      6: 
                      7: 
                      8: A buffer is a portion of  memory set aside to hold data read from
                      9: or to  be written to another process  or device.  Often, although
                     10: not always,  this involves setting  aside a portion  of the arena
                     11: with malloc or its related functions.
                     12: 
                     13: Buffering,  and problems  therewith, are  encountered  most often
                     14: when using the  standard input and output (STDIO) routines.  Many
                     15: operating systems  (including COHERENT) automatically  place data
                     16: from a peripheral device  into a buffer.  Buffers normally can be
                     17: cleared  with fflush,  by  pressing the  carriage  return key  on
                     18: routines that perform input, or by sending a newline character on
                     19: routines that perform  output.  The function fclose, which closes
                     20: a file  stream, flushes all buffers  associated with that stream.
                     21: exit calls fclose.
                     22: 
                     23: Combining unbuffered and  buffered I/O functions on the same file
                     24: or device  within one  program will  produce results that  are at
                     25: best unpredictable.
                     26: 
                     27: ***** Example *****
                     28: 
                     29: The following example  demonstrates what does and does not happen
                     30: when you use fffflluusshh with the output buffer.
                     31: 
                     32: 
                     33: #include <stdio.h>
                     34: main()
                     35: {
                     36:         extern char *malloc();
                     37:         char *buffer;
                     38: 
                     39: 
                     40: 
                     41:         /* use malloc() to create a 120-char buffer */
                     42:         if ((buffer = malloc(120)) == NULL) {
                     43:                 /* if malloc() fails, bail out */
                     44:                 fprintf(stderr, "malloc failed\n");
                     45:                 exit(1);
                     46:         }
                     47: 
                     48: 
                     49: 
                     50:         printf("Type your name:  ");
                     51:         fflush(stdout);
                     52:         gets(buffer);
                     53:         printf("Your name is %s\n", buffer);
                     54: }
                     55: 
                     56: 
                     57: ***** See Also *****
                     58: 
                     59: arena, array, close, definitions, exit, fflush, malloc, STDIO
                     60: 
                     61: 
                     62: 
                     63: 
                     64: COHERENT Lexicon                                           Page 1
                     65: 
                     66: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.