1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| #include <iostream> using namespace std; #include <string.h> void Myappend(char t1[],char t2[]); int my_strlen(const char *str); int main() { char a[20],b[20];
cout<<"Please enter a string:"<<endl; cin>>a; cout<<"Please enter a string:"<<endl; cin>>b; Myappend(a,b); return 0; }
void Myappend(char t1[],char t2[]) { int len1,len2; len1=my_strlen(t1); len2=my_strlen(t2); for(int i=0; i<=len2; i++) t1[len1+i]=t2[i]; cout<<t1<<endl;
} int my_strlen(const char *str) { int count =0; while(*str !='\0') { count++; str++; } return count; }
|