Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site callan.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!qantel!hplabs!sdcrdcf!trwrb!scgvaxd!wlbr!callan!tim From: tim@callan.UUCP (Tim Smith) Newsgroups: net.lang.c Subject: Re: C programming hint Message-ID: <1057@callan.UUCP> Date: Mon, 29-Jul-85 21:11:27 EDT Article-I.D.: callan.1057 Posted: Mon Jul 29 21:11:27 1985 Date-Received: Sat, 3-Aug-85 05:32:10 EDT References: <899@teddy.UUCP> Organization: Callan Data Systems, Westlake Village, CA Lines: 17 > char blanks[SIZE]; /* declare array of SIZE elements */ > > blanks[0] = ' '; /* initialize 1st element */ > > strncpy(blanks + 1, blanks, SIZE - 1); /* initialize entire array */ Danger Will Robinson! Danger Will Robinson! Non-portable contruct. Unsafe assumptions about implementation of strncpy. Danger Will Robinson! If strncpy is done in assembly for efficiency, and the machine has a block tranfer instruction, and the author of strncpy used it, and the machine is smart about copying strings, then the above will fail, because the machine will recognize that the source and destinations overlap, with the destination above the source, so it will copy the string from the back. -- Tim Smith ihnp4!{cithep,wlbr!callan}!tim