C programming hint
Dept 3271
gangal at petsd.UUCP
Fri Jul 12 00:37:15 AEST 1985
In article <899 at teddy.UUCP> kps at 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
More information about the Comp.lang.c
mailing list