views:

92

answers:

4

i see this warning How to do fix it?

Temp += (Table[i, temp3] - (MSB[i] ^ 0x1));

warning: left-hand operand of comma expression has no effect

+3  A: 

what is Table object? If it is 2-dimensional array then you should write

Table[i][temp3]

In your code

[i, temp3]

is a comma operator - it evaluates the 1st parameter (i), ignores it and returns temp3, so you can just drop i if Table is some kind of container that accepts single-index to access its objects

Vladimir
thank you very much when i do this it solved Tablo[i][temp3]
@user: consider accepting this answer, then. (Click the green arrow to the left of the answer.)
Bill
+1  A: 

The comma operator evaluates any number of expressions from left to right, and results in the value of the right-most one.

You have a comma in Table[i, temp3], which is exactly as doing Table[temp3]. Were you trying to do Table[i][temp3] to access a position in a bidimensional array?

edit: I'll explain some more, it may be useful for you. I won't be 100% precise, it's just to give you an idea of what's going on.

Why do you have to use two pairs of brackets to access a "cell" in your "table"? With one-dimensional arrays, array[i] will land you on the i-th element of the array, right? Well, with a two-dimensional array, let's call it table as you did, table[i] will land you on the i-th element as well. This time, though, that element is another array: the whole i-th row of the table.

So if table[i] is a row of the table, which is just another array, how do you access column j? Well, you have to go to row[j], which is table[i][j].

Multidimensional arrays in C are "arrays of arrays".

Santiago Lezica
+1  A: 

Wrong syntax - if Table is a two-dimentional array use Table[i][temp3].

Nikolai N Fetissov
+1  A: 

What do you mean by i, temp3? If Table is a 2D array, access element (i,temp3) with Table[i][temp3].

Edit: Since I was slow enough to be beat by several answers, I'll add something so that my answer isn't just a duplicate of earlier ones: What does i, temp3 really mean? Well, the C99 standard explains:

"The left operand of a comma operator is evaluated as a void expression; there is a sequence point after its evaluation. Then the right operand is evaluated; the result has its type and value.97) If an attempt is made to modify the result of a comma operator or to access it after the next sequence point, the behavior is undefined."

So Table[i, temp3] means "evaluate i, then access element number temp3 in Table. Thus the compiler warns you that the i isn't doing anything (since evaluating i doesn't produce any side-effects).

gspr