Array Troubles

While trying to call on an implemented array, the error message “LValue for ‘]’ operator must be a pointer” appears. What does this mean, and how should I fix this? In our code, our statements are along the lines of:
static int myArray[5]={100,200,300,400,500};
static int mode=3;

First, it is difficult to answer a general question about what is a very specific error message. If at all possible, take a screen shot of the first LValue error message from the error window and provide that. Also, provide at least the line of code which is flagged as causing the error. It would be more helpful for you to past all of the code into your question. Use the “code” tag to surround your code. It’s the button in the reply bar just to the left of the quote symbol, looks like </>.

Now, to take a stab at the general question: Any error message about an LValue means you are attempting to assign a value to something. An LValue is an all-encompassing term for any expression which is valid for the left hand side of an assignment statement. Given that, some assignment you attempted was incorrect, or some comparison you made looked like an attempt to assign something.

Posting the error and the code would be most helpful.

Here’s the initialization code that isn’t in the screenshot:

static int insideStack[13]={117,240,365,470,572,697,810,948,1052,1185,1307,1427,1612};
static int insideCones=0;

array troubles.jpg

What is “inStack”? You’ve told use what “insideStack” is, but not that.

By the look of the if statement little down the code, inStack is an unrelated boolean and the code inside the while condition should use insideStack, not inStack…

That’s what I was thinking, which is why I asked. Later on we see insideStack[insideCones] showing up. But, as you’ve said, inStack is being used as both a boolean and as an array name. Since the error shows up where it’s an array name, it is probably defined as a boolean.

so looking at the code in the while loop you are looking for inStack[insideCones] but above the image you have the array as insideStack for the name. Make sure the value you are checking for the array is actually the array name because inStack looks to be a boolean variable. I got the pointer error on test code when the array name didn’t match. that small change should help if it doesn’t feel free to explain the new issue or if it’s still the same.

p.s. here’s a snippet of my test code to see what your issue was, this code does work.

int inStack[5] = {100,200,300,400,500};
int insideCones = 0;

while (abs(inStack[insideCones] - SensorValue[encoder]) > 50){
	//insert code here