Rossj wrote:
I think C0X (and all of the others) define it as
int tictactoe[3][3]
so it must be a compiler extension.
I concur. It seems to dangerously conflict with the comma operator.
$ cat test.c
#include <stdio.h>
int main(void) {
int tictactoe[3,3];
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
tictactoe[i,j] = i * 3 + j;
printf("%d,%d: %d; ", i, j, i * 3 + j);
}
printf("\n");
}
printf("\n");
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
printf("%d,%d: %d; ", i, j, tictactoe[i,j]);
}
printf("\n");
}
return 0;
}
$ gcc -Wall --std=c99 test.c
test.c: In function `main':
test.c:4: warning: left-hand operand of comma expression has no effect
test.c:9: warning: left-hand operand of comma expression has no effect
test.c:19: warning: left-hand operand of comma expression has no effect
$ ./a.out
0,0: 0; 0,1: 1; 0,2: 2;
1,0: 3; 1,1: 4; 1,2: 5;
2,0: 6; 2,1: 7; 2,2: 8;
0,0: 6; 0,1: 7; 0,2: 8;
1,0: 6; 1,1: 7; 1,2: 8;
2,0: 6; 2,1: 7; 2,2: 8;
... so though gcc compiles this, it's just making a single-dimensional array with the last specified index.