![](https://static.youtibao.com/asksite/comm/h5/images/m_q_title.png)
用指针写合并两个字符串的函数。【分析与提示】先将字符串str1从串头到串尾逐一拷贝到字符串str3中,接着将字符串str2从串头到串尾逐一拷贝到字符串str3中。参考代码:#includecharunitestring(char*str1,char*str2,char*str3)/*合并函数*/{inti=0;while((*str1)!=‟\0‟){*(str3+i)=*str1;i++;str1++;}while((*str2)!=‟\0‟){*(str3+i)=*str2;i++;str2++;}*(str3+i)=‟\0‟;/*不能自动加入\0*/}main{charp[50],q[50],r[100];/*r为连接后的字符串*/printf("Pleaseenterthefirststring:\n");gets(p);/*输入字符串*/printf("Pleaseenterthesecondstring:\n");gets(q);/*输入字符串*/unitestring(p,q,r);puts(r);/*输出结果*/}。
![](https://static.youtibao.com/asksite/comm/h5/images/solist_ts.png)