Question: MakeShip() has the following function prototype: strict battleship makeShip (int. size, int pos); Input parameters: makeShip() takes as input the size and position of the
MakeShip() has the following function prototype: strict battleship makeShip (int. size, int pos); Input parameters: makeShip() takes as input the size and position of the ship. Return type: makeShip() returns a battleship structure. Functionality: makeShip() defines and initializes a battleship structure. It sets the battleship's member variables size and post based on its input parameters; it allocates a contiguous block of memory that is large enough to hold size integers and sets the member variable body to point to the start of the block: it assigns 1 to every element of body, which can be treated as an array with size elements after it has been allocated memory; and, finally, it returns the initialized battleship structure variable. Testing: Use the main source file test_1.c to test the functionality of makeShip(). Study this source file carefully since it will teach you how to (i) work with the battleship structure and (ii) write your own simple code to test functions
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
