#include "stdio.h"
int main()
{
char s[100]="hello";
char b[]="world";
int len=mystrlen(s);
printf("len=%d\n",len);
mystradd(s,b);
printf("s=%s\n",s);
}
int mystrlen(char s[]) //求字符串长度方法
{
int len=0;
char *p=s;
while(*p)
{
len++;
p++;
}
return len;
}
void mystradd(char s[],char b[]) //字符串连接方法;
{
int len=mystrlen(s);
char *ps=&s[len];
char *pb=b;
while(*pb)
{
*ps=*pb;
ps++;
pb++;
}
}
c语言-指针统计字符串长度,字符串连接
最新推荐文章于 2023-08-13 20:24:41 发布