My compiler generates the exact same MVC for both memcpy and strcpy: 00127 | 2 MVC t(8,r13,172),+CONSTANT_AREA(r2,0) ... 00121 | 2 MVC t(8,r13,172),char(r2,0)
Header 2 line 121 is the memcpy, header 2 line 127 is the strcpy David Logan Manager of Product Development, Pitney Bowes Business Insight http://centrus.com W: (720) 564-3056 C: (303) 818-8222 -----Original Message----- From: IBM Mainframe Discussion List [mailto:[EMAIL PROTECTED] On Behalf Of Kirk Wolf Sent: Monday, September 08, 2008 13:05 To: [email protected] Subject: Re: question for C experts - strcpy vs memcpy (Is this really a topic for IBM-MAIN?) FWIW, I would be surprised if most modern optimizing C compilers didn't generate the same exact code, as well as: memcpy(dest, "LITERAL", sizeof("LITERAL")+1); Kirk Wolf On Mon, Sep 8, 2008 at 1:25 PM, John McKown <[EMAIL PROTECTED]> wrote: > 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 > > ---------------------------------------------------------------------- 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 ---------------------------------------------------------------------- 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

