Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site decvax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!minow From: minow@decvax.UUCP (Martin Minow) Newsgroups: net.lang.c Subject: Re: String copy idiom. Message-ID: <55@decvax.UUCP> Date: Tue, 12-Mar-85 21:02:19 EST Article-I.D.: decvax.55 Posted: Tue Mar 12 21:02:19 1985 Date-Received: Thu, 14-Mar-85 04:40:52 EST References: <2040@sun.uucp> Lines: 17 On a vax, the fastest string copy is probably the non-obvious length = strlen(input); strncpy(output, input, length); (Assuming both routines are expanded in-line so you're not hit by the subroutine call overhead.) Note the following VMS Macro code from a routine in the Decus C library. .entry strcpy,^M movl 8(ap),r2 ; source string locc #0,#-1,(r2) ; find null at end of source subl2 r2,r1 ; length of source incl r1 ; plus 1 for the null byte movc3 r1,@8(ap),@4(ap); copy the string movl 4(ap),r0 ; r0 -> destination .end