Folks, I have been told that there is one logical problem with this code. Basically, this is an implementation of the library function strcat().
The intended beahviour of this function to concatenate ct to the end of s. Return s.
I could not find any logical problems with the code, apart from the fact that the final string should be NULL terminated, but I am not sure that can be classified as an error.
Could you help me find the error, if there is any.
char *strcat(char *s, const char *ct)
{
int i, start;
start = strlen(s);
for (i = 0; i < strlen(ct); i++)
{
s[start + i] = ct[i];
}
return s;
}
P.S. -
Is this the only correction needed in the code:
s[start+i]='\0'; \\after the loop