So in what way does it "not work"? By output I mean something like what it looks like and why it is wrong

Code:
.X.|...|...
---+---+---
...|.O.|...
---+---+---
...|...|...
That is an example output of the program snippet you showed, given appropriate values for the array - i'll use '.' to represent spaces. So what's wrong with it?