Laserlight, what if I inverted the order of my condition, namely:
Code:
while ((j != 0 && source[j - 1] != '\0') || !j) destination[i++] = source[j++];
Wouldn't that prevent the procedure from accessing a location out of bounds?
And regardless, suppose I wrote the following:
Code:
int main()
{
char arr1[60] = "abc";
char arr2[] = "abcffffff fldsflksfls";
my_strcat(arr1, arr2);
return 0;
}
void my_strcat (char destination[], const char source[])
{
int i = 0, j = 0;
while (destination[i] != '\0') i++;
destination[i++] = ' ';
while (source[j] != '\0') destination[i++] = source[j++];
printf("%s\n", destination);
}
Would you consider that to be a complete solution or is anything missing/unaccounted for?