自制字符串追加函数

#include "stdio.h"
#include "windows.h"

//自制字符串追加函数,功能相当于strcat
void MyStrcat(char *lpSrcStr,char *lpAppendStr)//参数1源字符串,2要追加的字符串
{
lpSrcStr+=strlen(lpSrcStr);  //字符串指针移到尾部
while(*lpAppendStr)   //如果有字符,循环添加
{
  *lpSrcStr ++ = *lpAppendStr ++; //添加,再后移指针
}
  *lpSrcStr = 0;    //添加字符串结束标记

}
int main()
{
char temp[50]="12347";  //字符串应给一定大小,否则可能溢出,当前为50
MyStrcat(temp,"*q11ass");
printf("%s \n",temp) ;  

return 0;
}

转载请说明出处,本文来自:【前线玩】http://www.qxwan.com/thread-141-1-3.html
如需了解更多,可访问 http://www.qxwan.com

posted on 2011-08-30 23:17  qxwan3  阅读(191)  评论(0)    收藏  举报