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

  1. /***
  2. *strset.c - sets all characters of string to given character
  3. *
  4. *       Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       defines _strset() - sets all of the characters in a string (except
  8. *       the '\0') equal to a given character.
  9. *
  10. *******************************************************************************/
  11.  
  12. #include <cruntime.h>
  13. #include <string.h>
  14.  
  15. #if defined (_M_ALPHA) || defined (_M_MRX000) || defined (_M_PPC) || defined (_M_MPPC)
  16. #pragma function(_strset)
  17. #endif  /* defined (_M_ALPHA) || defined (_M_MRX000) || defined (_M_PPC) || defined (_M_MPPC) */
  18.  
  19. /***
  20. *char *_strset(string, val) - sets all of string to val
  21. *
  22. *Purpose:
  23. *       Sets all of characters in string (except the terminating '/0'
  24. *       character) equal to val.
  25. *
  26. *
  27. *Entry:
  28. *       char *string - string to modify
  29. *       char val - value to fill string with
  30. *
  31. *Exit:
  32. *       returns string -- now filled with val's
  33. *
  34. *Uses:
  35. *
  36. *Exceptions:
  37. *
  38. *******************************************************************************/
  39.  
  40. char * __cdecl _strset (
  41.         char * string,
  42.         int val
  43.         )
  44. {
  45.         char *start = string;
  46.  
  47.         while (*string)
  48.                 *string++ = (char)val;
  49.  
  50.         return(start);
  51. }
  52.