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

  1. /***
  2. *fputws.c - write a string to a stream
  3. *
  4. *       Copyright (c) 1993-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       defines fputws() - writes a string to a stream
  8. *
  9. *******************************************************************************/
  10.  
  11.  
  12. #include <file2.h>
  13. #include <internal.h>
  14. #include <stdio.h>
  15. #include <mtdll.h>
  16. #include <tchar.h>
  17. #include <wchar.h>
  18. #include <dbgint.h>
  19.  
  20. /***
  21. *int fputws(string, stream) - write a string to a file
  22. *
  23. *Purpose:
  24. *       Output the given string to the stream, don't write the L'\0' or
  25. *       supply a L'\n'. Uses _stbuf and _ftbuf for efficiency reasons.
  26. *
  27. *Entry:
  28. *       wchar_t *string - string to write
  29. *       FILE *stream - stream to write to.
  30. *
  31. *Exit:
  32. *       Good return   = 0
  33. *       Error return  = WEOF
  34. *
  35. *Exceptions:
  36. *
  37. *******************************************************************************/
  38.  
  39. int __cdecl fputws (
  40.         const wchar_t *string,
  41.         FILE *stream
  42.         )
  43. {
  44.         unsigned int length;
  45.         int retval = 0;
  46.  
  47.         _ASSERTE(string != NULL);
  48.         _ASSERTE(stream != NULL);
  49.  
  50.         length = wcslen(string);
  51.  
  52.         _lock_str(stream);
  53.  
  54.         while (length--)
  55.         {
  56.             if (_putwc_lk(*string++, stream) == WEOF)
  57.             {
  58.                 retval = -1;
  59.                 break;
  60.             }
  61.         }
  62.  
  63.         _unlock_str(stream);
  64.  
  65.         return(retval);
  66. }
  67.  
  68.