博客首页 注册 建议与交流 排行榜 加入友情链接
推荐 投诉 搜索: 帮助

帅得不敢出门

热爱c++ 博客文章多为转载(帖子后面有带原文链接的)以做收藏 若有误处 望多多赐教
   stupidpig.cublog.cn
关于作者  
姓名:帅得不敢出门
职业:学生
年龄:23
位置:福州
C++群:24372952  3503799
个性介绍:交朋会友

我的分类  




strncat ( )【C语言库函数源代码】

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;

}

 原文地址 http://blog.csdn.net/ammana_babi/archive/2006/11/24/1409936.aspx
 发表于: 2008-05-31,修改于: 2008-05-31 14:11 已浏览232次,有评论0条 推荐 投诉

  网友评论

  发表评论



Copyright © 2001-2006 ChinaUnix.net All Rights Reserved

感谢所有关心和支持过ChinaUnix的朋友们
页面生成时间:0.01492

京ICP证041476号