strcpy: "after the null has been copied"

Peter J Desnoyers peter at athena.mit.edu
Sat Apr 9 00:34:35 AEST 1988


--
If strcpy is not constrained to copying characters only up to the
terminating null, then it is free to copy any characters after this
point. Hence I could write a conforming strcpy which would, in a
hardware-dependent manner, either erase my program or cause a write
protection error. (I know this isn't that hot an idea.)

The source of the confusion  seems to be this: 
 There are two orderings being referred to in this discussion.
Characters in memory are ordered by address, and characters are copied
in some chronological order. 

For the definition of strcpy to make sense, it must define the address
range to be modified in terms of the arguments, and thus refer to
ordering in memory space. It may be a nicety, but is not absolutely
necessary, for the definition to refer to ordering in time, as this
does not change the functionality for non-overlapping strings. 


				Peter Desnoyers
				peter at athena.mit.edu

[man strcpy gives me: "strcpy copies string s2 to s1, stopping after
the null character has been moved." This seems to refer to order in
time, and not explicitly refer to the memory range modified. I don't
think it is a very rigorous definition.]



More information about the Comp.lang.c mailing list