We have three operators in the mix: dereference, post-increment and assignment.
Make it four, there is an implicit conversion from a char to bool too.
Multiple operators. Who goes first? Precedence and order of evaluation.
The right side of assignment reads a char that the pointer src is pointing to and after that advances the pointer to next char.
On the left side the char from right side is assigned to where-ever the tgt points to and after that the tgt is advanced.
Testing the condition is the last step. We can rewrite the whole as equivalent do..while loop:
1 2 3 4 5 6 7
|
char result = '\0';
do {
*tgt = *src;
result = *tgt;
++src;
++tgt;
} while ( result );
|
A C-string is an array of characters. The last character in it is null ('\0'). Null converts to false. Thus, when the last character has been copied, the condition is false and the loop ends.
After the loop the src points one past the null of the original string.
After the loop the tgt points one past the null of the new string.