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

  1. /***
  2. *scanf.c - read formatted data from stdin
  3. *
  4. *       Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       defines scanf() - reads formatted data from stdin
  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 scanf(format, ...) - read formatted data from stdin
  21. *
  22. *Purpose:
  23. *       Reads formatted data from stdin into arguments.  _input does the real
  24. *       work here.
  25. *
  26. *Entry:
  27. *       char *format - format string
  28. *       followed by list of pointers to storage for the data read.  The number
  29. *       and type are controlled by the format string.
  30. *
  31. *Exit:
  32. *       returns number of fields read and assigned
  33. *
  34. *Exceptions:
  35. *
  36. *******************************************************************************/
  37.  
  38. int __cdecl scanf (
  39.         const char *format,
  40.         ...
  41.         )
  42. /*
  43.  * stdin 'SCAN', 'F'ormatted
  44.  */
  45. {
  46.         int retval;
  47.  
  48.         va_list arglist;
  49.  
  50.         va_start(arglist, format);
  51.  
  52.         _ASSERTE(format != NULL);
  53.  
  54.         _lock_str2(0, stdin);
  55.  
  56.         retval = (_input(stdin,format,arglist));
  57.  
  58.         _unlock_str2(0, stdin);
  59.  
  60.         return(retval);
  61. }
  62.