海洋之心


私信TA

用户名:wanggongsheng

访问量:122700

签 名:

等  级
排  名 17
经  验 20531
参赛次数 3
文章发表 163
年  龄 26
在职情况 学生
学  校
专  业 计算机技术

  自我简介:

读研ing,平时不登录dotcpp

#include<stdio.h>
#include<string.h>
void mystrcat(char s1[],char s2[]);
int main(void)
{
	char s1[100];
	char s2[100];
	scanf("%s%s",s1,s2);
	mystrcat(s1,s2);
	printf("%s",s1);
	return 0;
}
void mystrcat(char s1[],char s2[])
{
	while(*s1)s1++;
	while(*s1++=*s2++);
}


 

0.0分

11 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区

这样好像也行

#include<stdio.h>
int main()
{
	char a[100],b[100];
	scanf("%s%s",a,b);
	printf("%s%s",a,b);
	return 0;
}
2020-09-10 13:47:08
while(*s1)s1++;
    while(*s1++=*s2++);
s1是数组各个元素地址,*s1是元素的值. while(*s1)s1++;  中s1++是地址一直++,直到*s1为0(也就是字符串末尾)
此时s1指向字符串末尾
同理  while(*s1++=*s2++);就是把s2的元素++,然后赋值给s1++
2020-06-26 17:34:38
s1++;
数组名可以自增吗?
2020-06-07 23:25:06
牛逼
2020-05-16 12:19:53
确实妙
2020-05-09 10:41:19
#include<stdio.h>
char x[1000],y[1000];
void main(void){
int L,LL;
void QQ(int,int);

scanf("%s%s",&x,&y);
L=strlen(x);
LL=strlen(y);
QQ(L,LL);
x[L+LL-1]='\0';
printf("%s\n",x);

}

void QQ(a,b){
     int m=0,i;
	for(i=a;i<a+b;i++){x[i]=y[m];m++;}
			
}
//这个提示错误,我找不到原因,难道字符里的空格也要算吗?
2020-03-25 12:01:45
while(*s1)s1++;
    while(*s1++=*s2++);
大佬,可以解释一下吗?
2020-03-09 11:34:24
妙呀
2020-02-25 18:59:30
  • «
  • 1
  • »