[SOLVED] Problem assigning values to array

wire_amps[8][1] = 1,47;

The infamous C comma operator, bane of newbs.

In C and C++, the expression 2 + 3 has the value 5. + is an operator. Likewise, , is also an operator. It takes two values, and the result is always the value of the right-hand operand. What's the use of that? Well, bot operands are always evaluated. If they do something that has side-effects (a function call, an assignment), then those side-effects happen.

This is quite distinct from using the comma in an initializer, or in the argument list in a function call. In those case, the compiler interprets the comma as a delimiter. Here, however, the comma is part of an expression and will be interpreted as an operator.

The compiler is interpreting this expression like so:

[nobbc](wire_amps[8][1] = 1), (47);[/nobbc]

Both sub-expressions get evaluated. The first operand is an assignment, which gets executed. The second operand is the constant 47. The value of the whole expression is 47, but nothing gets done with that value and that's ok.

Oh BTW, @gfvalvo is also correct about writing past array bounds. The usual symptom of this is that your sketch crashes or behaves in mind-bogglingly unpredictable ways. That isn't happening here (yet), but is likely to happen if your sketch becomes more complicated with more global variables.