修改后的程序:
#include
using namespace std;
int main()
{
char s1[80],s2[40];
int i=0,j=0;
cin>>s1;
cin>>s2;
while(s1[i]!='\0')
i++;
while(s2[j]!='\0')
s1[i++]=s2[j++];
s1[i]='\0';
cout<
}
自己对照下就知道错在哪里了,不懂再说。
while(s1!='\0')
i++;
while(s1[i]!='\0')
s1[i++]=s2[j++];
改为
while(s1[i]!='\0')
i++;
while(s2[j]!='\0')
s1[i++]=s2[j++];
while(s1!='\0')//改为s1[i]!='\0'
i++;
while(s1[i]!='\0')//改为s[j]!='\0'
s1[i++]=s2[j++];
s1[i]='\0';