I am working with an array of structs. here is the definition of the struct:
typedef struct fanStruct{
int brightness;
int speed;
int bladeCount;
int fanDiameter;
int modbusAddress;
unsigned char fanState;
unsigned char lightState;
unsigned char isLightKit;
char fanName[20];
}FanArray;
I can read from the array just fine with something like this: fans_progBar_1_7.position = fanArray[0].speed;
However nothing ive tried seems to work for reassigning the values inside the array.
for example fanArray[1][1] = 1; fanArray[1].speed = 1; both return invalid declarator errors.
Any help is appreciated.
assign values to an array of structs
- jovana.medakovic
- mikroElektronika team
- Posts: 986
- Joined: 18 Dec 2018 10:36
Re: assign values to an array of structs
Hello,
The name of struct, FanArray, is the same like the name of the array, fanArray. The difference is only in the first letter.
So, try to change one of the names or go to Tools -> Options -> Output Settings and turn on Case Sensitive.
Kind regards,
Jovana
The name of struct, FanArray, is the same like the name of the array, fanArray. The difference is only in the first letter.
So, try to change one of the names or go to Tools -> Options -> Output Settings and turn on Case Sensitive.
Kind regards,
Jovana
Re: assign values to an array of structs
I tried selecting case sensitivity as well as renaming the array and im still not able to assign values to variables inside each individual struct within the array.
is this the correct syntax?
arrayOfFans[1].speed = 1;
the compiler says its expecting a semicolon but finding a period.
is this the correct syntax?
arrayOfFans[1].speed = 1;
the compiler says its expecting a semicolon but finding a period.
- jovana.medakovic
- mikroElektronika team
- Posts: 986
- Joined: 18 Dec 2018 10:36
Re: assign values to an array of structs
Hi,
Yes, this is correct syntax, I tested it and I can build without any errors.
Can you tell me which version of the compiler you are using?
Can you zip and send me your project for review?
Also, send me a screenshot of the errors which you got?
Kind regards,
Jovana
Yes, this is correct syntax, I tested it and I can build without any errors.
Can you tell me which version of the compiler you are using?
Can you zip and send me your project for review?
Also, send me a screenshot of the errors which you got?
Kind regards,
Jovana
Re: assign values to an array of structs
oh my goodness, i'm in the wrong compiler forum. I should be in microC Pro for pic32.
my apologies, ill move my thread over there.
my apologies, ill move my thread over there.