Reputation: 822
I was going through a possible implementation method for library function strcpy
. It is :
void strcpy(char *src, char *dest)
{
while (*dest++ = *src++)
;
}
How can this possibly work without check of '\0'
??
Upvotes: 3
Views: 4403
Reputation: 241583
The result of *dest++ = *src++
is the value of *src
before the increment of src
. If this value is \0
, the loop terminates.
Upvotes: 6