我是靠谱客的博主 怕黑小丸子,这篇文章主要介绍c语言-指针统计字符串长度,字符串连接,现在分享给大家,希望可以做个参考。

#include "stdio.h"
int main()
{
char s[100]="hello";
char b[]="world";
int len=mystrlen(s);
printf("len=%dn",len);
mystradd(s,b);
printf("s=%sn",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语言-指针统计字符串长度,字符串连接的全部内容,更多相关c语言-指针统计字符串长度内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(58)

评论列表共有 0 条评论

立即
投稿
返回
顶部