Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site petsd.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!mtuxo!mtunh!mtung!mtunf!ariel!vax135!petsd!gangal From: gangal@petsd.UUCP (Dept 3271) Newsgroups: net.lang.c Subject: Re: C programming hint Message-ID: <576@petsd.UUCP> Date: Thu, 11-Jul-85 10:37:15 EDT Article-I.D.: petsd.576 Posted: Thu Jul 11 10:37:15 1985 Date-Received: Sat, 13-Jul-85 09:32:06 EDT References: <899@teddy.UUCP> Reply-To: gangal@petsd.UUCP (Robert Philhower) Organization: Perkin-Elmer DSG, Tinton Falls, N.J. Lines: 19 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: > > blanks[0] = ' '; /* initialize 1st element */ > strncpy(blanks + 1, blanks, SIZE - 1); /* initialize entire array */ 1) This probably uses a loop (in strncpy) 2) I don't know exactly what the standard C library does, but many string copy routines (in micro-code or higher level) check for overlapping strings and would process your request in reverse to avoid just the recursion you want. (For instance, you may have a string in there to which you want to prepend a character.) bob