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

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