Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: strcpy ques...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 17 Topic 26073 of 26972
Post > Topic >>

Re: strcpy question

by Eric Sosman <Eric.Sosman@[EMAIL PROTECTED] > May 5, 2008 at 02:39 PM

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]

 




 17 Posts in Topic:
strcpy question
mdh <mdeh@[EMAIL PROTE  2008-05-05 11:19:59 
Re: strcpy question
Eric Sosman <Eric.Sosm  2008-05-05 14:39:35 
Re: strcpy question
=?ISO-8859-1?Q?Tom=E1s_=D  2008-05-05 11:39:39 
Re: strcpy question
David Thompson <dave.t  2008-05-19 03:59:51 
Re: strcpy question
Keith Thompson <kst-u@  2008-05-18 21:39:15 
Re: strcpy question
=?ISO-8859-1?Q?Tom=E1s_=D  2008-05-05 11:41:33 
Re: strcpy question
"Default User"   2008-05-05 18:47:03 
Re: strcpy question
mdh <mdeh@[EMAIL PROTE  2008-05-05 13:08:56 
Re: strcpy question
=?ISO-8859-1?Q?Tom=E1s_=D  2008-05-05 14:34:55 
Re: strcpy question
mdh <mdeh@[EMAIL PROTE  2008-05-05 16:04:37 
Re: strcpy question
"Default User"   2008-05-05 23:16:18 
Re: strcpy question
Keith Thompson <kst-u@  2008-05-05 16:23:24 
Re: strcpy question
mdh <mdeh@[EMAIL PROTE  2008-05-05 16:07:12 
Re: strcpy question
mdh <mdeh@[EMAIL PROTE  2008-05-05 16:52:00 
Re: strcpy question
Keith Thompson <kst-u@  2008-05-05 18:00:22 
Re: strcpy question
mdh <mdeh@[EMAIL PROTE  2008-05-05 16:52:33 
Re: strcpy question
mdh <mdeh@[EMAIL PROTE  2008-05-05 18:17:13 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 16:02:54 CDT 2008.