home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 1.ddi / CLIBSRC1.ZIP / STRNSET.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.3 KB  |  53 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.  *      C/C++ Run Time Library - Version 5.0
  11.  *
  12.  *      Copyright (c) 1987, 1992 by Borland International
  13.  *      All Rights Reserved.
  14.  *
  15.  */
  16.  
  17.  
  18. #include <string.h>
  19. #include <mem.h>
  20.  
  21. /*---------------------------------------------------------------------*
  22.  
  23. Name            strnset - sets all characters in a string to a given
  24.                           character
  25.  
  26. Usage           char *strnset(char *str, int ch, size_t n);
  27.  
  28. Prototype in    string.h
  29.  
  30. Description     strnset sets up to the first n bytes of the string str to the
  31.                 character ch. If n > strlen(str), then strlen(str) replaces n.
  32.  
  33. Return value    pointer to str
  34.  
  35. *---------------------------------------------------------------------*/
  36. #undef strnset                  /* not an intrinsic */
  37.  
  38. #if defined(__FARFUNCS__)
  39. #include <_farfunc.h>
  40. #endif
  41.  
  42. char * _FARFUNC strnset(char _FAR *s, int ch, size_t n)
  43. {
  44.         unsigned len;
  45.  
  46.         len = strlen(s);
  47.         if (len < n)
  48.                 n = len;
  49.         setmem(s, n, ch);
  50.         return (s);
  51. }
  52.  
  53.