strcat(字符串1,字符串2) :将2连接到1后面,并返回字符串1
用指针和数组
#include
#include
#include
using namespace std;
char a[100],b[200];
int main()
{
int i,j;
char *p1,*p2;
p1=a;
p2=b;
gets(a);
gets(b);
for(;*p1!='\0';*p1++); //非常关键,使得p1的值递增,读取完p1.方便在后面复制p2的值
for(;*p2!='\0';*p1++,*p2++)
{
*p1=*p2;
}
*p1='\0';
puts(a);
return 0;
}
单纯只用数组结合
#include
#include
using namespace std;
int main()
{int i,j;
char s1[200],s2[100];
cout
关注
打赏