42 lines
553 B
C++
42 lines
553 B
C++
/*
|
|
|
|
Our implementation of strcat
|
|
|
|
*/
|
|
|
|
#include <iostream>
|
|
#include <cstring>
|
|
|
|
using namespace std;
|
|
|
|
void ourStrCat(char dest[], char src[]){
|
|
int i=0;
|
|
int j=0;
|
|
|
|
// get to the end of dest
|
|
while(dest[i] != '\0'){
|
|
i++;
|
|
}
|
|
// now i points to end of dest
|
|
while(src[j] != '\0'){
|
|
dest[i+j] = src[j];
|
|
j++;
|
|
}
|
|
// j points to end of src
|
|
dest[i+j] = '\0';
|
|
//dest[i]+dest[j]
|
|
}
|
|
|
|
int main() {
|
|
char string1[100];
|
|
char string2[100];
|
|
|
|
cin >> string1;
|
|
cin >> string2;
|
|
|
|
ourStrCat(string1,string2);
|
|
|
|
cout << string1 << endl;
|
|
|
|
}
|