Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site cadovax.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!talcott!panda!genrad!decvax!tektronix!hplabs!sdcrdcf!trwrb!trwrba!cadovax!brent
From: brent@cadovax.UUCP (Brent Rector)
Newsgroups: net.lang.c
Subject: Re: C programming hint
Message-ID: <708@cadovax.UUCP>
Date: Fri, 12-Jul-85 15:48:56 EDT
Article-I.D.: cadovax.708
Posted: Fri Jul 12 15:48:56 1985
Date-Received: Wed, 17-Jul-85 06:45:43 EDT
References: <899@teddy.UUCP>
Reply-To: brent@cadovax.UUCP (Brent Rector)
Organization: Contel Cado, Torrance, CA
Lines: 26
Keywords: strncpy

In article <899@teddy.UUCP> kps@teddy.UUCP (Kesavan P. Srinivasan) writes:
>I found a way to initialize an array of characters without using a loop.
>Here is the method I used:
>
>	char blanks[SIZE];	/* declare array of SIZE elements */
>	
>	blanks[0] = ' ';	/* initialize 1st element */
>
>	strncpy(blanks + 1, blanks, SIZE - 1);	/* initialize entire array */
>		   ^^^       ^^^       ^^^
>		    |         |         |
>		destination  source   how many characters to copy 
>

It seems to me that all you have done is to move the loop into the
strncpy function at the cost of additional procedure call.  Also while
I expect the above will generally work I can think of a couple of bizarre
ways to implement strncpy that would cause the above to fail.  In general
I think overlapped moves produce machine dependent results.

-- 
--------------------------------------------------------------
Brent E. Rector - CONTEL CADO, Torrance, CA
{ decvax, hplabs, ihnp4, ucbvax, sdcrdcf }!trwrb!cadovax!brent
   { onecom, philabs, scgvaxd, ttidca, ucla-cs }!cadovax!brent
				 cadovax!brent@ucla-locus.ARPA