I have this piece of code but I don't know what it means. If anyone could explain that would be helpful for me. I think this is an array of structs, am I right?
struct Snake
{
int x, y;
} s[225];
CodePudding user response:
You're right. It's an array of structure Snake
.
You can store information of multiple Snake
in there (in your code 225
snake information can be stored as you took size of the array
as 225
).
For example:
s[0].x = any_int_value;
s[0].y = any_int_value;
....
There're many other ways to access and assign values. To learn more about array of structure, please check following resources
- Array of Structures vs. Array within a Structure in C/C
- C Array of Structures
- Array of Structures in C
CodePudding user response:
I think this is an array of structs, am I right?
You are right. The name of the class is Snake
, the name of the array is s
and the array has 225 elements and the type of the elements is Snake
.