void strcpy(char *s, char *t)
{
int i;
i = 0;
while ((*s = *t) != '\0') {
s++;
t++;
}
}
I made a function to copy string t
to string s
using pointers from K&R.
The while loop uses (*s = *t)!='\0'
which is supposed to mean that to run loop till the we reach the end of t
string
but I didn't understand how it works,
According to me: when the end is reached s
gets '\0'
in end so it got assigned but how the comparision of this is made with !='\0'
part, does the bracket (*s=*t)
returned '\0'
in end and then it is compared and the loop is ended?