Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: Notesfiles $Revision: 1.7.0.5 $; site uiucdcsb Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!inuxc!pur-ee!uiucdcsb!seefromline From: johnston@uiucdcsb.Uiuc.ARPA Newsgroups: net.lang.c Subject: Re: C programming hint Message-ID: <139200009@uiucdcsb> Date: Thu, 18-Jul-85 10:04:00 EDT Article-I.D.: uiucdcsb.139200009 Posted: Thu Jul 18 10:04:00 1985 Date-Received: Sat, 20-Jul-85 05:15:54 EDT References: <899@teddy.UUCP> Lines: 18 Nf-ID: #R:teddy.UUCP:-89900:uiucdcsb:139200009:000:651 Nf-From: uiucdcsb.Uiuc.ARPA!johnston Jul 18 09:04:00 1985 /* Written 2:04 pm Jul 10, 1985 by kps@teddy.UUCP in uiucdcsb:net.lang.c */ /* ---------- "C programming hint" ---------- */ 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 The trick is to use strncpy in an almost recursive way. Well, I hope you found this useful. /* End of text from uiucdcsb:net.lang.c */