More on strcpy()
00704a-Liber
nevin1 at ihlpf.ATT.COM
Fri Apr 15 01:31:41 AEST 1988
In article <904 at mit-caf.UUCP> vlcek at mit-caf.UUCP (Jim Vlcek) writes:
>Why not define strcpy() such that the destination is guaranteed to be
>equivalent to the original (before the move) source string? While
>this *suggests* an implementation, it does not out-and-out *specify*
>it, yet it still seems to me to provide the behavior desired.
One problem with this method is that the length of the source string must
be known *first* in order to get the copy completely right. This is not as
efficient as the way strcpy() is usually defined; ie,
'while (*dst++ = *src++);', because two passes are required over the src
string (one to find the length and one to perform the copy).
The other problem I have with this definition, as well as with the proposal
that strcpy() be defined as having the same result as the 'while' loop I
stated above, is that strcpy() can LEGALLY be used to modify the *src*
string. It is this property becoming legal that I object to.
--
_ __ NEVIN J. LIBER ..!ihnp4!ihlpf!nevin1 (312) 510-6194
' ) ) "The secret compartment of my ring I fill
/ / _ , __o ____ with an Underdog super-energy pill."
/ (_</_\/ <__/ / <_ These are solely MY opinions, not AT&T's, blah blah blah
More information about the Comp.lang.c
mailing list