第6周笔记8-字符串连接

字符串连接

        将两个字符串连接起来,不用strcat。

/*
将两个字符串连接起来,不用strcat。 
*/ 

#include<stdio.h>
#define N 100
int main(){
	char str1[2*N],str2[N];
	scanf("%s%s",str1,str2);
	char *p=str1,*q=str2;
	
	while(*p!='\0') p++;
	for(;*q!='\0';p++,q++)	*p=*q;
	*p='\0';
	printf("%s\n",str1);
	return 0;
}
发布了152 篇原创文章 · 获赞 53 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/weixin_41297324/article/details/102599591