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.

64 lines
1.5 KiB

  1. /***
  2. *strncat.c - append n chars of string to new string
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines strncat() - appends n characters of string onto
  8. * end of other string
  9. *
  10. *Revision History:
  11. * 05-31-89 JCR C version created.
  12. * 02-27-90 GJF Fixed calling type, #include <cruntime.h>, fixed
  13. * copyright.
  14. * 10-02-90 GJF New-style function declarator.
  15. * 09-02-93 GJF Replaced _CALLTYPE1 with __cdecl.
  16. *
  17. *******************************************************************************/
  18. #include <cruntime.h>
  19. #include <string.h>
  20. /***
  21. *char *strncat(front, back, count) - append count chars of back onto front
  22. *
  23. *Purpose:
  24. * Appends at most count characters of the string back onto the
  25. * end of front, and ALWAYS terminates with a null character.
  26. * If count is greater than the length of back, the length of back
  27. * is used instead. (Unlike strncpy, this routine does not pad out
  28. * to count characters).
  29. *
  30. *Entry:
  31. * char *front - string to append onto
  32. * char *back - string to append
  33. * unsigned count - count of max characters to append
  34. *
  35. *Exit:
  36. * returns a pointer to string appended onto (front).
  37. *
  38. *Uses:
  39. *
  40. *Exceptions:
  41. *
  42. *******************************************************************************/
  43. char * __cdecl strncat (
  44. char * front,
  45. const char * back,
  46. size_t count
  47. )
  48. {
  49. char *start = front;
  50. while (*front++)
  51. ;
  52. front--;
  53. while (count--)
  54. if (!(*front++ = *back++))
  55. return(start);
  56. *front = '\0';
  57. return(start);
  58. }