home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / s / snip1292.zip / FERRORF.C < prev    next >
C/C++ Source or Header  |  1992-01-05  |  666b  |  25 lines

  1. /*  FERRORF.C
  2. **  Prints error message with printf() formatting syntax, then a colon,
  3. **  then a message corressponding to the value of errno, then a newline.
  4. **  Output is to filehandle.
  5. **
  6. **  Public Domain by Mark R. Devlin, free usage is permitted.
  7. */
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <stdarg.h>
  12.  
  13. int ferrorf(FILE *filehandle, const char *format, ...)
  14. {
  15.     int vfp, fp;
  16.     va_list vargs;
  17.  
  18.     vfp = fp = 0;
  19.     va_start(vargs, format);
  20.     vfp = vfprintf(filehandle, format, vargs);
  21.     va_end(vargs);
  22.     fp = fprintf(filehandle, ": %s\n", sys_errlist[errno]);
  23.     return ((vfp==EOF || fp==EOF) ? EOF : (vfp+fp));
  24. }
  25.