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

  1. /***
  2. *wcsnset.c - set first n wide-characters to single wide-character
  3. *
  4. *       Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       defines _wcsnset() - sets at most the first n characters of a
  8. *       wchar_t string to a given character.
  9. *
  10. *******************************************************************************/
  11.  
  12.  
  13. #include <cruntime.h>
  14. #include <string.h>
  15.  
  16. /***
  17. *wchar_t *_wcsnset(string, val, count) - set at most count characters to val
  18. *
  19. *Purpose:
  20. *       Sets the first count characters of string the character value.
  21. *       If the length of string is less than count, the length of
  22. *       string is used in place of n (wide-characters).
  23. *
  24. *Entry:
  25. *       wchar_t *string - string to set characters in
  26. *       wchar_t val - character to fill with
  27. *       size_t count - count of characters to fill
  28. *
  29. *Exit:
  30. *       returns string, now filled with count copies of val.
  31. *
  32. *Exceptions:
  33. *
  34. *******************************************************************************/
  35.  
  36. wchar_t * __cdecl _wcsnset (
  37.         wchar_t * string,
  38.         wchar_t val,
  39.         size_t count
  40.         )
  41. {
  42.         wchar_t *start = string;
  43.  
  44.         while (count-- && *string)
  45.                 *string++ = (wchar_t)val;
  46.  
  47.         return(start);
  48. }
  49.  
  50.