Annotation of coherent/a/usr/man/ALL/fflush, revision 1.1

1.1     ! root        1: 
        !             2: 
        !             3: fflush()                  STDIO Function                 fflush()
        !             4: 
        !             5: 
        !             6: 
        !             7: 
        !             8: Flush output stream's buffer
        !             9: 
        !            10: #include <stdio.h>
        !            11: iinntt fffflluusshh(_f_p) FFIILLEE *_f_p;
        !            12: 
        !            13: fflush flushes any  buffered output data associated with the file
        !            14: stream fp.   The file stream  stays open after  fflush is called.
        !            15: fclose calls fflush, so there is  no need for you to call it when
        !            16: normally closing a file or buffer.
        !            17: 
        !            18: ***** Example *****
        !            19: 
        !            20: This  example demonstrates  fflush.  When run,  you will  see the
        !            21: following:
        !            22: 
        !            23: 
        !            24:         Line 1
        !            25:         -----
        !            26:         Line 1
        !            27:         -----
        !            28:         Line 1
        !            29:         Line 2
        !            30:         -----
        !            31: 
        !            32: 
        !            33: The call
        !            34: 
        !            35: 
        !            36:         fprintf(fp, "Line 2\n");
        !            37: 
        !            38: 
        !            39: goes to a buffer and is  not in the file when file foo is listed.
        !            40: However if you redirect the output  of this program to a file and
        !            41: list the file, you will see:
        !            42: 
        !            43: 
        !            44:         Line 1
        !            45:         Line 1
        !            46:         Line 1
        !            47:         Line 2
        !            48:         -----
        !            49:         -----
        !            50:         -----
        !            51: 
        !            52: 
        !            53: because the line
        !            54: 
        !            55: 
        !            56:         printf("-----\n");
        !            57: 
        !            58: 
        !            59: goes into a  buffer and is not printed until  the program is over
        !            60: and all buffers are flushed by exit().
        !            61: 
        !            62: 
        !            63: 
        !            64: COHERENT Lexicon                                           Page 1
        !            65: 
        !            66: 
        !            67: 
        !            68: 
        !            69: fflush()                  STDIO Function                 fflush()
        !            70: 
        !            71: 
        !            72: 
        !            73: Although  the  COHERENT  screen  drivers  print  all  output  im-
        !            74: mediately, not  all operating systems  work this way,  so when in
        !            75: doubt, fflush().
        !            76: 
        !            77: 
        !            78: #include <stdio.h>
        !            79: 
        !            80: 
        !            81: 
        !            82: main()
        !            83: {
        !            84:         FILE *fp;
        !            85: 
        !            86: 
        !            87: 
        !            88:         if (NULL == (fp = fopen("foo", "w")))
        !            89:                 exit(1);
        !            90:         fprintf (fp, "Line 1\n");
        !            91:         fflush (fp);
        !            92:         system ("cat foo"); /* print Line 1 */
        !            93: 
        !            94: 
        !            95: 
        !            96:         printf("-----\n");
        !            97:         fprintf(fp, "Line 2\n");
        !            98:         system("cat foo"); /* print Line 1 */
        !            99:         printf("-----\n");
        !           100: 
        !           101: 
        !           102: 
        !           103:         fflush(fp);
        !           104:         system("cat foo"); /* print Line 1 Line 2 */
        !           105:         printf("-----\n");
        !           106: }
        !           107: 
        !           108: 
        !           109: ***** See Also *****
        !           110: 
        !           111: fclose(), setbuf(), STDIO, write()
        !           112: 
        !           113: ***** Diagnostics *****
        !           114: 
        !           115: fflush returns  EOF if it cannot flush the  contents of the buff-
        !           116: ers; otherwise it returns a meaningless value.
        !           117: 
        !           118: Note, also, that  all STDIO routines are buffered.  fflush should
        !           119: be used to flush the output  buffer if you follow a STDIO routine
        !           120: with an unbuffered routine.
        !           121: 
        !           122: 
        !           123: 
        !           124: 
        !           125: 
        !           126: 
        !           127: 
        !           128: 
        !           129: 
        !           130: COHERENT Lexicon                                           Page 2
        !           131: 
        !           132: 

unix.superglobalmegacorp.com

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