Question
This is for C Programming: I am working on a Battleship project and creating the folloiwng two functions to initialize the board and print the
This is for C Programming:
I am working on a Battleship project and creating the folloiwng two functions to initialize the board and print the board. The boards, two , one for player and one for computer. I am getting the following errors and issues but do not know how to fix them. Please take a look at it and see how I can fix it and make it better. Thank you so much.
MY CODE:
#include
#include
/*Each Player's game board would be intialized
no ships have been placed on either board */
void initializeBoard()
{
const int rows = 10,
cols = 10;
int playerBoard[rows][cols],
compBoard[rows][cols];
{
for (int i=0; i
{
for(int j=0; j
{
playerBoard[i][j] = '-';
compBoard[i][j] = '-';
}
}
}
}
//prints the game board for the player and computer
void printBoard()
{
const int rows = 10,
cols = 10;
int playerBoard[rows][cols],
compBoard[rows][cols];
{
for (int i=0; i
{
for(int j=0; j
{
printf("%c ", playerBoard[i][j]);
if (i == 10)
puts(""); //only triggers if i=10, 10x10grid
}
}
}
puts(" ");
for(int i = 0; i
{
for(int j = 0; j
{
printf("%c", compBoard[i][j]);
if (i == 10)
puts("");
}
}
}
int main(void)
{
initializeBoard();
printboard();
return 0;
}
ERRORS AND WARNINGS:
b113@LAPTOP-8HTJec97:/mnt/c/Users/cecil/COP3530/Projects/Project initializeBoard.c: In function main': s gcc initializeBoard.c-o initializeBoard initializeBoard.c:71:2: warning: implicit declaration of function 'printboard' [-Wimplicit-function-declaration] printboard); /tmp/ccA2gxzB.o: In function main' initializeBoard.c:(.text+0x697): undefined reference to "printboard cb113@LAPTOP-8HTJC97: mnt/c/Users/cecil/COP3530/Projects/Project2/Workupproj2 s ./initializeBoard bash: ./initializeBoard: No such file or directory
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started