[LIP] const char * in strcpy

"Pramathesh Ambasta" <[email protected]>
Newsgroups gmane.user-groups.linux.india.programmers
Message-ID <[email protected]>
   If this sounds like a novice question, it is. So please bear 
with
it.
Why does the definition of the standard library function strcpy
specify const char * as its second argument?
Given that the source string has to be copied to the target, 
should
not the target be const char * (in the sense of an array name, 
which
points to a constant memory location but where the contents of 
the
memory location may be changed)?
Char * as the first argument could also mean a pointer to a 
constant
(literal) or an (as yet) unitialised pointer. Using such pointers 
to
write to the memory locations they point to is risky and could 
lead
to all kinds of instability. To use it in the first argument seems 
to
suggest that it is alright to write to such memory locations.
On the other hand to specify const char * as the second argument
seems unnecessary because the source string could well be a 
literal

Could the gurus please enlighten?
Pramathesh


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.