The string literal is also null terminated so the 8th character copied
will be correct.

-----Original Message-----
From: Patrick Roehl [mailto:snip] 
Sent: Monday, September 08, 2008 11:47 AM
To: [email protected]
Subject: Re: question for C experts - strcpy vs memcpy

strcpy and memcpy do different things.  Remember that C strings are
null-terminated.  strcpy(dest,"LITERAL") will move 8 bytes (7 for the
literal plus the terminator).  memcpy(dest,"LITERAL",8) will try to move
8 bytes, but what you get after "LITERAL" is not defined.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to