题目描述
将2行英文连接后输出。不能使用strcat函数。
要求:编写函数f(char s1,char s2,char s3),将字符指针s1中字符与字符指针s2中字符连接到到字符指针s3中。
输入
输入包括2行英文。
输出
将2行英文连接后输出。
样例输入
Problems involving the computation of exact values of very large magnitude and precision are common.
For example, the computation of the national debt is a taxing experience for many computer systems.
样例输出
Problems involving the computation of exact values of very large magnitude and precision are common.For example, the computation of the national debt is a taxing experience for many computer systems.
#include<stdio.h>
#include<string.h>
void f(char *s1,char *s2,char *s3)
{
int i=0,l;
for(;*s1!='\0';)
{
*s3=*s1;
s3++;
s1++;
}//s3的数值已经变了,假如s2有10个元素,结束时s3也有十个元素
for(;*s2!='\0';)//所以s3开始时是s3[9]
{
*s3=*s2;
s3++; //s3在原来的基础上加1
s2++;
}
*s3='\0';//字符串必须以'\0'结束
}
int main()
{
char s1[20000],s2[20000],s3[40000];
char *q=s3;
gets(s1);
gets(s2);
f(s1,s2,s3);
printf("%s\n",q);
return 0;
}
以上我个人见解,如有什么错误请指出,谢谢