"Algorithm Notes" Section 3.6 - Getting Started Analog -> string processing
A no difficulty, attention is at a plus \ 0 character after the end of that occupation [0, len1-1], then the \ 0 in the len1
At the beginning of strlen do not directly determine the \ 0 before you can determine the length
#include<stdio.h> #include<string.h> int main() { char a[1000]; char b[1000]; while(scanf("%s %s",a,b)!=EOF) { int len1,len2; len1=0;len2=0; while(a[len1]!='\0') len1++; while(b[len2]!='\0') len2++; //printf("len1:%d len2:%d\n",len1,len2); for(int i=0;i<=len2-1;i++) a[i+len1]=b[i]; a[len1+len2]='\0'; printf("%s\n",a); } return 0; }