A89: Re: A C question


[Prev][Next][Index][Thread]

A89: Re: A C question





Hi!

| I have a question about C.  Lets say I have a sprite and it looks like
this:
|
| static unsigned int block[] = {0xFF,0xC3,0xA5,0x99,0x99,0xA5,0xC3,0xFF};
|
| And I wanted to save that to a temporary sprite.  How would I go about
| storing that sprite into a different sprite.  I tried this:
|
| static unsigned int temp[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
| .
| .
| .
| temp = block;

Simply assigning it wouldn't work in this case, I think.  Try 'memcpy' from
'mem.h'.  It would look something like this (although I don't know if the
'sizeof' works that way):

memcpy (&temp, &block, sizeof (temp));

Moreover, you probably want to use 'char' instead of 'int', because it seems
to be an 8x8 sprite.  Otherwise it won't work correctly.

Bye,
Sebastian Reichelt




Follow-Ups: References: