This is an old revision of the document!
A structure is an always-public class. For this project, we'll be using one to group together the code we need for our Breakout brick.
Format the code similarly to a class:
struct Brick { int positionX; int positionY; ... };
Remember that for structures, a semicolon is needed after the closing curly brace. You'll get an error otherwise.
Malloc, short for “memory allocation,” does what it says on the tin.
For Breakout, we need to allocate the amount of memory needed to hold our entire brick field (AKA the array of brick structs). We do that by using the sizeof
function:
BrickArray = ( [Brick structure]* ) malloc( sizeof( [Brick structure] ) * [Number of bricks] );