I need help writing this program, I am stuck, the following are the directions:
This is what I am supposed to do:
1.To start, create an array filled with the character O (for Ocean).
2.Generate a random number to be the index of the Battleship.
3.Allow the user three guesses to find the location of the Battle ship
4.After each guess you should print the board
5.Previously guessed locations should appear as the character X
6.A message should print if the user guesses a previously guessed location
7.After three (incorrect) guesses you win
8.If the user correctly guesses the location, they wine
Problems: It currently does not build it gives me a problem for Size in the statement: char board [SIZE]; & I am unsure why if in the rest of the program it doesn't do it. Also I am unsure on how to print the X's for what the user enters. Thanks.
This is what I currently Have:
using namespace std;
int SIZE= 10;
char board [SIZE];
fill(board, board+10, 'O');
int index = rand() % 11;
cout<<"Let's Play Battleship!!" << endl;
for (int i=0; i<SIZE; i++)
cout << board[i] <<" ";
cout <<"Enter a guess from 0 to 10";
cin >> answer;
if (answer >= 0 && answer < SIZE)
board[answer] = 'X';