home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / fprintf.c < prev    next >
C/C++ Source or Header  |  1998-06-17  |  2KB  |  70 lines

  1. /***
  2. *fprintf.c - print formatted data to stream
  3. *
  4. *       Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       defines fprintf() - print formatted data to stream
  8. *
  9. *******************************************************************************/
  10.  
  11. #include <cruntime.h>
  12. #include <stdio.h>
  13. #include <dbgint.h>
  14. #include <stdarg.h>
  15. #include <file2.h>
  16. #include <internal.h>
  17. #include <mtdll.h>
  18.  
  19. /***
  20. *int fprintf(stream, format, ...) - print formatted data
  21. *
  22. *Purpose:
  23. *       Prints formatted data on the given using the format string to
  24. *       format data and getting as many arguments as called for
  25. *       _output does the real work here
  26. *
  27. *Entry:
  28. *       FILE *stream - stream to print on
  29. *       char *format - format string to control data format/number of arguments
  30. *       followed by arguments to print, number and type controlled by
  31. *       format string
  32. *
  33. *Exit:
  34. *       returns number of characters printed
  35. *
  36. *Exceptions:
  37. *
  38. *******************************************************************************/
  39.  
  40. int __cdecl fprintf (
  41.         FILE *str,
  42.         const char *format,
  43.         ...
  44.         )
  45. /*
  46.  * 'F'ile (stream) 'PRINT', 'F'ormatted
  47.  */
  48. {
  49.         va_list(arglist);
  50.         REG1 FILE *stream;
  51.         REG2 int buffing;
  52.         int retval;
  53.  
  54.         va_start(arglist, format);
  55.  
  56.         _ASSERTE(str != NULL);
  57.         _ASSERTE(format != NULL);
  58.  
  59.         /* Init stream pointer */
  60.         stream = str;
  61.  
  62.         _lock_str(stream);
  63.         buffing = _stbuf(stream);
  64.         retval = _output(stream,format,arglist);
  65.         _ftbuf(buffing, stream);
  66.         _unlock_str(stream);
  67.  
  68.         return(retval);
  69. }
  70.