home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / CLIB1.ZIP / STRNSET.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  1.7 KB  |  49 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - strnset.c
  3.  *
  4.  * function(s)
  5.  *        strnset - sets all characters in a string to a given
  6.  *                 character
  7.  *-----------------------------------------------------------------------*/
  8.  
  9. /*[]------------------------------------------------------------[]*/
  10. /*|                                                              |*/
  11. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  12. /*|                                                              |*/
  13. /*|                                                              |*/
  14. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  15. /*|     All Rights Reserved.                                     |*/
  16. /*|                                                              |*/
  17. /*[]------------------------------------------------------------[]*/
  18.  
  19. #include <string.h>
  20. #include <mem.h>
  21.  
  22. /*---------------------------------------------------------------------*
  23.  
  24. Name            strnset - sets all characters in a string to a given
  25.                   character
  26.  
  27. Usage           char *strnset(char *str, int ch, size_t n);
  28.  
  29. Prototype in    string.h
  30.  
  31. Description     strnset sets up to the first n bytes of the string str to the
  32.                 character ch. If n > strlen(str), then strlen(str) replaces n.
  33.  
  34. Return value    pointer to str
  35.  
  36. *---------------------------------------------------------------------*/
  37. #undef strnset                  /* not an intrinsic */
  38. char *strnset(char *s, int ch, size_t n)
  39. {
  40.     unsigned len;
  41.  
  42.     len = strlen(s);
  43.     if (len < n)
  44.         n = len;
  45.     setmem(s, n, ch);
  46.     return (s);
  47. }
  48.  
  49.