Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.3 KiB

  1. /***
  2. *strnset.c - set first n characters to single character
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines _strnset() - sets at most the first n characters of a string
  8. * to a given character.
  9. *
  10. *Revision History:
  11. * 02-27-90 GJF Fixed calling type, #include <cruntime.h>, fixed
  12. * copyright.
  13. * 08-14-90 SBM Compiles cleanly with -W3
  14. * 10-02-90 GJF New-style function declarator.
  15. * 01-18-91 GJF ANSI naming.
  16. * 09-03-93 GJF Replaced _CALLTYPE1 with __cdecl.
  17. *
  18. *******************************************************************************/
  19. #include <cruntime.h>
  20. #include <string.h>
  21. /***
  22. *char *_strnset(string, val, count) - set at most count characters to val
  23. *
  24. *Purpose:
  25. * Sets the first count characters of string the character value.
  26. * If the length of string is less than count, the length of
  27. * string is used in place of n.
  28. *
  29. *Entry:
  30. * char *string - string to set characters in
  31. * char val - character to fill with
  32. * unsigned count - count of characters to fill
  33. *
  34. *Exit:
  35. * returns string, now filled with count copies of val.
  36. *
  37. *Exceptions:
  38. *
  39. *******************************************************************************/
  40. char * __cdecl _strnset (
  41. char * string,
  42. int val,
  43. size_t count
  44. )
  45. {
  46. char *start = string;
  47. while (count-- && *string)
  48. *string++ = (char)val;
  49. return(start);
  50. }