home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a120 / 1.ddi / WATCOM_C / WAT59.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-18  |  898 b   |  43 lines

  1. /*------------------------------------------------------------------*/
  2. /* ╡{ªí└╔ªW║┘: wat59.c                                              */
  3. /*------------------------------------------------------------------*/
  4. #include <string.h>
  5. #include <stdio.h>
  6. #include <conio.h>
  7. #include <io.h>
  8.  
  9. void flush(FILE *stream);
  10.  
  11. void main()
  12. {
  13.    FILE *fp;
  14.    char msg[] = "dup() ¿τ╝╞ñº┤·╕╒╜m▓▀";
  15.  
  16.    /* ½╪Ñ▀ñ@¡╙└╔«╫ */
  17.    fp = fopen("MYFILE.TXT", "w");
  18.  
  19.    /* ╝gñJñ@¿╟╕Ω«╞ª▄ª╣└╔«╫ññ */
  20.    fwrite(msg, strlen(msg), 1, fp);
  21.  
  22.    printf("╜╨½÷Ñ⌠ñ@┴Σ╢}⌐l╝gñJ MYFILE.TXT");
  23.  
  24.    getch();
  25.  
  26.    /* ªbñú├÷│¼ MYFILE.TXT ñº¬¼║AñU▒N╕Ω«╞╝gñJ MYFILE.TXT */
  27.    flush(fp);
  28.  
  29.    printf("\n└╔«╫ñw│Q╝gñJ, ╜╨½÷Ñ⌠ñ@┴Σ┬≈╢} ");
  30.    getch();
  31. }
  32.  
  33. void flush(FILE *stream)
  34. {
  35.    int duphandle;
  36.  
  37.    fflush(stream);
  38.  
  39.    /* ╜╞╗sñ@¡╙└╔«╫▒▒╗s╜X */
  40.    duphandle = dup(fileno(stream));
  41.    close(duphandle);
  42. }
  43.