Reactos
at master 56 lines 1.4 kB view raw
1/*** 2*strncat.c - append n chars of string to new string 3* 4* Copyright (c) Microsoft Corporation. All rights reserved. 5* 6*Purpose: 7* defines strncat() - appends n characters of string onto 8* end of other string 9* 10*******************************************************************************/ 11 12#include <string.h> 13 14/*** 15*char *strncat(front, back, count) - append count chars of back onto front 16* 17*Purpose: 18* Appends at most count characters of the string back onto the 19* end of front, and ALWAYS terminates with a null character. 20* If count is greater than the length of back, the length of back 21* is used instead. (Unlike strncpy, this routine does not pad out 22* to count characters). 23* 24*Entry: 25* char *front - string to append onto 26* char *back - string to append 27* unsigned count - count of max characters to append 28* 29*Exit: 30* returns a pointer to string appended onto (front). 31* 32*Uses: 33* 34*Exceptions: 35* 36*******************************************************************************/ 37 38char * __cdecl strncat ( 39 char * front, 40 const char * back, 41 size_t count 42 ) 43{ 44 char *start = front; 45 46 while (*front++) 47 ; 48 front--; 49 50 while (count--) 51 if ((*front++ = *back++) == 0) 52 return(start); 53 54 *front = '\0'; 55 return(start); 56}