Re: [LIP] const char * in strcpy

"Josy P. Pullockara" <[email protected]>
Newsgroups gmane.user-groups.linux.india.programmers
Organization National Aerospace Laboratories
Message-ID <[email protected]>
On Wed, 2004-07-28 at 13:02, Pramathesh Ambasta wrote:
> 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)?

You got the (const char*) and (char* const) mixed up. Look up Stroustrup
for this discussion with regard to C++. I am sure K&R should be
discussing about this in case of C.

(const char* p) means the data pointed to by 'p' is const
(char* const p) means the pointer 'p' is const
(const char* const p) means the pointer 'p' and the data pointed to by
'p' are both constants.

So, the library declaration for strcpy is absolutely correct.
-- 
Josy P. Pullockara <[email protected]>
National Aerospace Laboratories



-------------------------------------------------------
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.