Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site alice.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: net.lang.c Subject: Re: C programming hint Message-ID: <3976@alice.UUCP> Date: Thu, 11-Jul-85 10:57:56 EDT Article-I.D.: alice.3976 Posted: Thu Jul 11 10:57:56 1985 Date-Received: Sat, 13-Jul-85 07:51:56 EDT References: <899@teddy.UUCP> Organization: Bell Labs, Murray Hill Lines: 13 > 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 Don't. There is no guarantee that strncpy copies one character at a time.