home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / prof_c / util / string.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  346 b   |  24 lines

  1. /*
  2.  *    string -- emit a sequence of n repetitions of the
  3.  *    character ch 
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8.  
  9. int
  10. string(n, ch, fp)
  11. int n;
  12. char ch;
  13. FILE *fp;
  14. {
  15.     register int i;
  16.  
  17.     for (i = 0; i < n; ++i)
  18.         if (fputc(ch, fp) == EOF && ferror(fp))
  19.             break;
  20.  
  21.     /* return number of actual repetitions */
  22.     return (i);
  23. }
  24.