bug with array?

I have this variables:
int p = 7; // p is 7 from the beginning
int n = 4; // n is 4 from the beginning
int y = 5; // y is changing in a loop
int i // value is not important, it changes in a loop

this structure:
struct w
{
int r = 0;
int nr;
};

and this arrays:
w wheel[n];
int customers[p];

but when it gets to this conditional operator:
wheel[y].r = (y < p ? customers[i] : p+1);

it's giving the value p+1 to wheel[y].r even though y = 5 and p = 7

I changed the conditional operator with and if and an else, I even tried if and else if but it has the same result.

So if anyone knows if this is a bug in Code::Blocks or if I made a mistake please let me know.

thanks for reading !
It is most likely you that has made a mistake. I can't guess what it is though because I haven't seen the real code.
Last edited on
Topic archived. No new replies allowed.