Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1396333
  • 博文数量: 143
  • 博客积分: 10005
  • 博客等级: 上将
  • 技术积分: 1535
  • 用 户 组: 普通用户
  • 注册时间: 2006-10-23 17:25
个人简介

淡泊明志 宁静致远

文章分类

全部博文(143)

文章存档

2011年(2)

2009年(1)

2007年(22)

2006年(118)

我的朋友

分类: C/C++

2006-11-23 14:48:04

C语言库函数源代码】

【本程序在Dev C++ 4.9.9.2 下编译通过】

/*

   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).

   把src所指字符串的前n个字符添加到dest结尾处(覆盖dest结尾处的'\0')并添加'\0'。

   src和dest所指内存区域不可以重叠且dest必须有足够的空间来容纳src的字符串。

   返回指向dest的指针。

*/

char * my_strncat(char *dest,const char *source,int count)

{

   char *p = dest;

   while (*p) p++;

   while (count-- && (*p++ = *source++));

   *p = '\0';

   return(dest);

}

int main()

{

   char a[20] = "ammana_";

   puts(my_strncat(a,"babi",10));

   system("pause");

   return 0;

}

阅读(1507) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~