Battleship c++ game

Just getting back into c++ and am taking a college course where they have us make a simple battleship game using arrays. I just had a couple of questions about some of the things I'm trying to do.

First off for the game loop can you do something like

while(seenBoard != board)

where you are comparing all the values in one array to another? Since in the seenBoard array after every entry it is posted to the screen I have it as all 'O's with ship placement on the board array marked with 'X's. We are suppose to use functions and right now I'm stuck on trying to get the seenBoard update with 'X's for hits. Here are my two functions I'm trying to get to work so that the board will update:



Thanks in advance for any suggestions :-)
Last edited on
You are creating a board every time. Why not just create the board once:

1
2
3
4
5
6
char seenBoard[4][4] = {
{'O','O','O','O'},
{'O','O','O','O'},
{'O','O','O','O'},
{'O','O','O','O'}
};


then print the board:
[code]
#include <string>
void PrintBoard()
{
string t;
for(int x = 0; x < 4; x++)
{
for(int y = 0; y < 4; y++)
{
t += seenBoard[x][y];
}
cout<<t<<endl;
t.clear();
}
};
[code]


Topic archived. No new replies allowed.