If you know the length of the field to be copied, the memcpy is preferred. Memcpy generates an MVC instruction in the compilation, the strcpy generates a call to a routine that does the strcpy. When you can use the mem functions(memcpy, memcmp, memset) it will reduce your overhead.
-----Original Message----- From: IBM Mainframe Discussion List [mailto:[EMAIL PROTECTED] On Behalf Of John McKown Sent: Monday, September 08, 2008 2:25 PM To: [email protected] Subject: question for C experts - strcpy vs memcpy If I am copying literal text into a char array, which do you think is better: strcpy(dest,"LITERAL"); OR memcpy(dest,"LITERAL",8); ?? I lean towards memcpy because the C run-time reference says that it is a builtin function and done in-line. Which I would guess would mean better performance. Why don't I just look at the generated code? Because I don't have a C compiler for z/OS. I'm writing my code on Linux using GCC. -- Q: What do theoretical physicists drink beer from? A: An EIN stein. Maranatha! John McKown ---------------------------------------------------------------------- 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 ----------------------------------------- The information contained in this e-mail message is intended only for the personal and confidential use of the recipient(s) named above. This message may be an attorney-client communication and/or work product and as such is privileged and confidential. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail, and delete the original message. ---------------------------------------------------------------------- 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

