C programming hint

Chris Torek chris at umcp-cs.UUCP
Fri Jul 12 08:02:33 AEST 1985


> 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 */

Beware, that won't work on Vax systems that use movc3 for string copies
(probably Sys VR2V2.2.2.2... [sorry :-)] and 4.3 both).
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at maryland



More information about the Comp.lang.c mailing list