C question: Nested sturctures and arrays with Xcode?

Right, if you omit the *, you are telling C to copy the value from RLLBlock to the block member of thePiece. Your Piece_Init function passes a sprite_ptr, which is different than passing the actual sprite. In order to obtain the value of a pointer, you have to de-reference the pointer using the * operator. So in your Piece_Init function you needed piece->block = *sprite. Perhaps looking at it another way might help. An alternative way to do that would be to change your function signature and how you call your function.

Blacktiger Wrote:Right, if you omit the *, you are telling C to copy the value from RLLBlock to the block member of thePiece. Your Piece_Init function passes a sprite_ptr, which is different than passing the actual sprite. In order to obtain the value of a pointer, you have to de-reference the pointer using the * operator. So in your Piece_Init function you needed piece->block = *sprite. Perhaps looking at it another way might help. An alternative way to do that would be to change your function signature and how you call your function.

Just leaving it blank didn't work. So I looked back and combined what worked before into one line, the (sprite_ptr)& from the function prototype, and the asterisk from the line itself, and surprisingly it worked:

That technique may be necessary if piece->block is a different type of struct than RLLBlock. I've certainly used it more than a few times. However, is this actually the case? And if it is, are you sure it's what you really meant to do?