//linux源码
#ifndef __HAVE_ARCH_STRNCAT /** * strncat - Append a length-limited, %NUL-terminated string to another * @dest: The string to be appended to * @src: The string to append to it * @count: The maximum numbers of bytes to copy * * Note that in contrast to strncpy(), strncat() ensures the result is * terminated. */ char *strncat(char *dest, const char *src, size_t count) { char *tmp = dest; if (count) { while (*dest) dest++; while ((*dest++ = *src++) != 0) { if (--count == 0) { *dest = ' '; break; } } } return tmp; } EXPORT_SYMBOL(strncat); #endif
//标准C源码
/****strncat.c - append n chars of string to new string** Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.**Purpose:* defines strncat() - appends n characters of string onto* end of other string********************************************************************************/#include <cruntime.h>#include <string.h>/****char *strncat(front, back, count) - append count chars of back onto front**Purpose:* Appends at most count characters of the string back onto the* end of front, and ALWAYS terminates with a null character.* If count is greater than the length of back, the length of back* is used instead. (Unlike strncpy, this routine does not pad out* to count characters).**Entry:* char *front - string to append onto* char *back - string to append* unsigned count - count of max characters to append**Exit:* returns a pointer to string appended onto (front).**Uses:**Exceptions:********************************************************************************/char * __cdecl strncat ( char * front, const char * back, size_t count ){ char *start = front; while (*front++) ; front--; while (count--) if (!(*front++ = *back++)) return(start); *front = ' '; return(start);}