C programming hint
Ron Natalie <ron>
ron at brl-tgr.ARPA
Fri Jul 12 07:56:31 AEST 1985
> I found a way to initialize an array of characters without using a loop.
> Here is the method I used:
>
> strncpy(blanks + 1, blanks, SIZE - 1); /* initialize entire array */
> ^^^ ^^^ ^^^
> The trick is to use strncpy in an almost recursive way.
We call this "almost recursion" iteration, and all it does is hide the
loop in the strncpy function.
> Well, I hope you found this useful.
No, not really.
-Ron
More information about the Comp.lang.c
mailing list