I'm reading a book the c programming language authored by Brian W. Kernighan and Dennis M. Ritchie.
The book lists code below
void strcpy(char *s, char *t){
while((*s = *t) != '\0'){
s++;
t++;
}
}
and says:
Because arguments are passed by value, strcpy can use the parameters s and t in any way it pleases
which I'm not agreed with. Why above arguments are passed by value?
According to another book C how to program:
In C, you use pointers and the indirection operator to simulate call-by reference. When calling a function with arguments that should be modified, the addresses of the arguments are passed.
In latter point of view, it's definitely call-by-reference.
Please tell me which way is correct and why, thanks!
btw, after assignment *s = *t
, which one is compared with '\0'
? *s
or *t
?