I working on a game board for a battleship game, this is what I have for the gameboard function:
Code:
int board [10] [10];
char water = '~';
int r, c; //r = rows, c = columns
for (r = 0; r < 10; r++)
{ for (c = 0; c < 10; c++)
printf(" %c ", water);
if (c == 10)
printf(" \n ");
c = 0; //reset column count to 0
basically at this point I can print the board but it isn't the board. I could take my array out of this and still have the same result. that isn't good. I am trying to print the board as
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
etc. but I also need them to have a value so when a player enters a coordinate 2 3, it will tell if it is a hit or not. I'll use a pointer for that. My question is how to assign coordinates to my array while printing the water on the screen.
*disclosure: this code is mine (for what it's worth) any help would be appreciated.