My 2 cents embedded...

> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of Shraddhan
> Sent: Friday, October 21, 2005 1:50 PM
> To: [email protected]
> Subject: Re: [C-Paradise] Need for Strcpy pointer 2 return 2 first element
> 
> char * p = strcpy("apples", "bananas");
> 
> This may, or may not, change the string "bananas" to "apples", depending
> on whether it is in RAM or ROM, but in any case  the pointer p will point
> to the string. But again, you could have written the code as:
> 
> char * p = "apples";
> strcpy(p, "bananas");

The results of this and previous strcpy() would be "undefined".  But I think
you already know that :)

 
> So, as I see it, the only useful value that strcpy could have been defined
> to return would be a pointer to the end of the string copied, or else a
> count of the number of characters copied. Or it should have been defined
> as void, and not return a value at all.

Indeed, IMHO, return the pointer to the end of the resulting string could be
more useful than pointer to the beginning of the destination.  This could
make strcat() obsolete and make concatenate multiple strings lot faster.

Return a count of the number of characters copied is equally useful.  


> Anand Shraddhan
> 
> (There is a deliberate bug in the above code...)

Shyan





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/EbFolB/TM
--------------------------------------------------------------------~-> 

>-----------------------------------------~-~>
CHECK THE ARCHIVE BEFORE POSTING!!!! Archive is available at 
http://www.eScribe.com/software/C-Paradise/

>------------------------------------------_->


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/C-Paradise/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to