home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc_prog / chap16 / badputc.i < prev    next >
Encoding:
Text File  |  1988-04-07  |  598 b   |  23 lines

  1. /* badputc.I -- preprocessed putfile.c          */
  2. /*  Not shown are all the stdio.h contents that */
  3. /*  come at the top of the file.                */
  4.  
  5. main()
  6. {
  7.     struct _iobuf *fp;
  8.     int ch;
  9.     if ((fp = fopen("junk", "w")) == 0)
  10.         exit(1);
  11.  
  12.    /* original was while ((ch = getchar()) != EOF) */
  13.     while ((ch = (--((&_iob[0]))->_cnt >= 0 ? 0xff &
  14.        *((&_iob[0]))->_ptr++ : _filbuf((&_iob[0]))))
  15.        != (-1))  
  16.  
  17.    /* original was putch(fp, ch); */  
  18.         (--(ch)->_cnt >= 0 ? 0xff &
  19.     (*(ch)->_ptr++ = (fp)) : _flsbuf((fp),(ch)));
  20.  
  21.     fclose(fp);
  22. }
  23.