Re: Meggy Jr. Programming Syntax Question

Home Evil Mad Scientist Forums LED Matrix Kits Meggy Jr. Programming Syntax Question Re: Meggy Jr. Programming Syntax Question

#21003
Windell Oskay
Keymaster
In what you’ve written above, it’s failing because you are trying to declare a new Point, but the two elements of new Point both need to be of type int, not of type Point.  

For the same reason, your line above marked “This works fine” actually should not work fine.  (When I test it, it fails– like it should!)

It looks like you want to instead declare an array of Points.  To do so, you might declare and initialize the array as follows:

struct Point myArray[] = { s1, s2 };

 

Alternately, declare and then initialize the array like so:
struct Point myArray[2];
myArray[0] = s1;
myArray[1] = s2;
To change the values of the int values within a Point, you can use:
s1.x = 4;
s1.y = 5;
After doing so, you can then the values in the array:
myArray[1] = s1;