I posted this code elsewhere to get insight on why it didn't output "ratdog" as expected. Someone said there wasn't enough room to append "dog" to "rat" or something. What did they mean?
#include <stdio.h>
char *strcat(char*, char*);
char* strcat(char *s, char *t) {
char* result = *s;
while(*s != '\0')
printf("%s", *s);
*s++; // advance pointer until you reach the null terminator.
while(*t != '\0')
*s = *t; // copy t to the end of s until we reach the end of t.
return (char*) result;
}
int main() {
char rat[] = "rat";
char dog[] = "dog";
printf("%s", strcat(rat, dog));
return 0;
}