Hey guys, I'm new here but I could use some help. I don't want to post a wall of code so I'll try to be short and specific here. I'm trying to pass an array of structures and assign values to each member but am being told the title. Can someone tell me what it means and how I can go about fixing it? Thanks!
constint fleetSize = 5; // number of battleships
constint fieldSize = 5; // the field (ocean) is fieldSize * fieldSize
// coordinates (Location) of the ship and shots
struct Location {
int x; // 1 through fieldSize
char y; // 'a' through fieldSize
};
// contains ship's coordinates (Location) and whether is was sunk
struct Ship {
Location loc;
bool sunk;
};
//
// initialization functions
//
void initialize(Ship[]); // places every Ship in a Location where x-coordinate is -1
// and y-coordinate is '*' (a star) to signify
// that the Ship is not deployed
battleship.cpp
1 2 3 4 5 6 7 8 9 10
#include "battleship.h"
void initialize (int a[])
{
for (int i = 0; i < fleetSize; i++)
{
a[i].loc.x = -1;
a[i].loc.y = '*';
}
}
testShips.cpp
1 2 3 4 5 6 7 8 9
main()
{
Ship myFleet[fleetSize];
initialize(myFleet); //assigning -1 to all ship's Locations in myFleet
printFleet(myFleet);
}