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

  1. /***
  2. *printf.c - print formatted
  3. *
  4. *       Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       defines printf() - print formatted data
  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 printf(format, ...) - print formatted data
  21. *
  22. *Purpose:
  23. *       Prints formatted data on stdout using the format string to
  24. *       format data and getting as many arguments as called for
  25. *       Uses temporary buffering to improve efficiency.
  26. *       _output does the real work here
  27. *
  28. *Entry:
  29. *       char *format - format string to control data format/number of arguments
  30. *       followed by list of arguments, 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 printf (
  41.         const char *format,
  42.         ...
  43.         )
  44. /*
  45.  * stdout 'PRINT', 'F'ormatted
  46.  */
  47. {
  48.         va_list arglist;
  49.         int buffing;
  50.         int retval;
  51.  
  52.         va_start(arglist, format);
  53.  
  54.         _ASSERTE(format != NULL);
  55.  
  56.         _lock_str2(1, stdout);
  57.  
  58.         buffing = _stbuf(stdout);
  59.  
  60.         retval = _output(stdout,format,arglist);
  61.  
  62.         _ftbuf(buffing, stdout);
  63.  
  64.         _unlock_str2(1, stdout);
  65.  
  66.         return(retval);
  67. }
  68.