Arrays and stuff

Stan Brown browns at iccgcc.decnet.ab.com
Sat Feb 16 07:20:43 AEST 1991


In article <26915 at uflorida.cis.ufl.EDU>, jdb at reef.cis.ufl.edu (Brian K. W. Hook) writes:
> Basically, you can initialize an array with values, and you can't
> re-initialize after declaration.  However, if I wanted to put a string into
> an array I could use strcpy(), but I want to fill in the entire array with
> a predefined array: in effect:
>      char array[NUMBER][SIZE];
>      array[number]={ ...assorted values...};
> How do I do this?  I want different bitmasks for a cursor depending on what
> the user does, but I can't seem to implement this very easily unless
> I use:
>      char *mask;
>      mask=&array[0][0];
> or
>      strcpy(mask,array[0]);
> But this is a pain for certain things that I am doing.  And I DEFINITELY
> don't want to do:
>      array[0][0]=0x44;
>      array[0][1]=0x99;
> etc. etc. 

Use memcpy not strcpy:
	memcpy(array[n], mask, SIZE);
will copy SIZE bytes from mask to array[n].

memcpy is declared in <string.h>

Hey--this is all my opinion, nobody else's. Rely on it at your peril.
"no yucky green things"            email: browns at iccgcc.decnet.ab.com
Stan Brown, Oak Road Systems, Cleveland, Ohio, USA    +1 216 371 0043



More information about the Comp.lang.c mailing list