The prototype of the function is: void myjoin(char *s,char *t);, its function is to connect the t string to the back of the s string. The main function for testing is shown below, please make the function myjoin.
#include <stdio.h>
#include <string.h>
void main()
{
void myjoin(char *s,char *t);
char s1[100],s2[100];
gets(s1);
gets(s2);
myjoin(s1,s2);
puts(s1);
}
The complete code is as follows:
#include<stdio.h>
#include <string.h>
void myjoin(char *s,const char *t)
{
int i,j;
for(i=0;s[i];i++)
{
;
}
for(j=0;t[j];j++,i++)
{
s[i]=t[j];
}
s[i]='\0';
}
void main()
{
char s1[100],s2[100];
gets(s1);
gets(s2);
myjoin(s1,s2);
puts(s1);
}
The result of the operation is shown in the figure:
Caicai's code, I hope it can help you!