不用string实现字符串连接
#include<iostream>
#include<cstdio>
#include<string.h>
#define N 100
using namespace std;
int main(void){
char a[N];
char b[N];
char c[2*N];
int i;
cout<<"请输入a:"<<endl;
cin>>a;
cout<<"请输入b:"<<endl;
cin>>b;
int lenght1;
int lenght2;
lenght1=strlen(a);
lenght2=strlen(b);
for(i=0;i<lenght1;i++){
c[i]=a[i];
}
for(i=lenght1;i<lenght1+lenght2;i++){
c[i]=b[i-lenght1];
}
c[lenght1+lenght2]=' ';
cout<<"连接完的字符串为:"<<c<<endl;
}
运行结果: