strcat()reads from the input and copies it to the output, until it finds a terminator \0at the input. By specifying the same array for both input and output, you change the input while reading.
You will need to check the specific implementation of your compiler strcat(), but if you follow through a simple implementation, as shown below, you should see why your code will work after a while:
char *strcat(char *dest, const char *src )
{
char *ret = dest;
if (dest && src)
{
while (*dest != 0)
++dest;
while (*str != 0)
*dest++ = *src++;
*dest = 0;
}
return ret;
}
while (*dest != 0) dest \0. while (*str != 0) a, , . , , , \0 .