Fun with arrays..

This is a discussion on Fun with arrays.. within the C Programming forums, part of the General Programming Boards category; I'm using a 2d array to make a kind of like a co-ordinate geometry effect. Where my array is oject[r][c], ...

In other words, you're scanning over the plane or grid. Think of a chessboard. If you have a "mailbox" type of a board representation (like my program does), you need to go over every square on the board, just this way, to find out which piece can move, where.

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

But what happens if im in a position where i don't need to use the if statement. (Just curious question) How would i print a charactar at a particular location of object[r][c]?

You would normally have defines for the program, like say your top row was actually on the 3rd row down on the screen.

So now you print everything in your grid relative to TopRow, which == 3. So the row you'll print to will be TopRow + row, and same with your columns - they'll all be printed up as LeftSide + column, because you might want to locate the board or grid, someplace else besides right on the very leftmost side of the screen.

To locate the right x and y points on the screen, you can use Goto(x,y) in Windows API, an example of which is located just now on the forum, not far below your own post.

You may need several if statements or a switch statement with several choices, to get all the char's you want printed on your grid.

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell