功能:将src的前n个字符添加到dest的后面
输入:dest,src,count
返回:ret
#include <iostream>
#include <assert.h>
using namespace std;
char * _strncat(char *dest,const char *src,int count)
{
assert((dest != NULL)&&(src != NULL));
char *ret = dest;
while(*dest != '\0') dest++;
while (count--)
{
if (!(*dest++ = *src++))
{
return ret;
} }
*dest = '\0';
return ret;
} int main()
{
char str1[20] = "abcdef";
char str2[20] = "hello world";
cout << _strncat(str1,str2,3)<<endl;
return 0;
};