I'm trying to direct the strncat function. I understand most of it and can write this a diff way, but I can't figure out how to write a longer version of while (!(*dest++ = *src++))
.
char *_strncat(char *dest, char *src, int n)
{
char *ret = dest;
while (*dest) /* same as: while (dest[0] !- '\0') */
{
dest++; /* w. each loop, array is shifted left until it's empty */
}
while (n != 0)
{
if (!(*dest++ = *src++)) /* <=========here */
return ret;
n--;
}
*dest = 0;
return (ret);
}
Can someone show and explain how to expand that line so I can direct it and learn how it works? Thanks!