mdh wrote:
> I have a question about the library function strcpy.
> In K&R on page 109, strcpy is used to copy a line ( line[] ) to a
> pointer (char *), which is first allocated space by K&Rs "alloc"
> function.
> In a few pages prior to this, the example that K&R showed used this
> definition for it's version of strcpy
>
> void strcpy( char *s, char *t){
>
> while ( *s++ = *t++);
>
> }
>
> Could someone help me understand the library function, which,
> according to the appendix, returns the target string.
> So, in this case, what is passed to the library is an array-the
> original string and a pointer to the target string? What happens if
> the target pointer has not been allocated space? And, is this
> acceptable ie to pass a pointer instead of an actual char array for
> the target string?
You will probably find it helpful to read Questions 6.3
and 6.4 in the comp.lang.c Frequently Asked Questions (FAQ)
list at <http://www.c-faq.com/>.
I'd suggest you go further
and read all of Section 6.
Your next-to-last question is Question 7.1, and Section 7
is another part you should probably read in its entirety --
but get through Section 6 first, for the groundwork it lays.
--
Eric.Sosman@[EMAIL PROTECTED]


|