On page 105, the authors provide the following example:
/* Strcpy: copy t to s */ void Strcpy(char *s, char *t){ while ((*s = *t) != '\0'){ s++; t++; } }The authors state:
Because arguments are passed by value, Strcpy can use the parameters s and t in any way it pleases.
Should there not be a caveat here that this freedom only applies to s and not t? For instance,
t[0] = '4'; //inside of Strcpywould be disastrous at the caller site.
That is, even though t within strcpy is a copy of whatever pointer is the actual argument (say T) at the calling site, i.e., aren't the following asserts valid
assert(&t != &T);//so, t is "different" from T assert(t == T);//yet they point to the same address in memoryGodbolt link of above : https://godbolt.org/z/Ycfxfess6
So, there extends to s some freedoms (for e.g., one can arbitrarily write into it garbage before doing the true copy) which t does not enjoy.
[link] [comments]

![[PROJECT] fread: TUI Text-File Reader written in C to view text files on your terminal](https://browardlocals.com/hello.gif)






English (US) ·