Question: int allocate_memory(player_t** player_p_p, long int nplayers) { /* This function allocates memory for a player_t pointer variable. Inputs: player_p_p - memory location of a player_t

int allocate_memory(player_t** player_p_p, long int nplayers)

{

/*

This function allocates memory for a player_t pointer variable.

Inputs:

player_p_p - memory location of a player_t pointer variable

nplayers - number of players that memory needs to be allocated for

Return:

0 - success

1 - failed to allocate memory

Post:

After the function has been called, *player_p_p will point to freshly

allocated memory if malloc was successful. Otherwise *player_p_p will point to

NULL.

*/

return 1; /* MODIFY */

}

void init_player(player_t* player_p, int age, int wickets)

{

/*

This function initialises each field of one playet_t struct.

Inputs:

player_p - memory location of the player_t variable. player_p must have been

allocated memory using allocate_memory before calling this function.

nplayers - number of players that memory needs to be allocated for

Post:

After the function has been called, the age field of *player_p will be the

input age, and wickets field of *player_p will be the input wickets.

*/}

void print_player(player_t player) { /* This function prints a player_t variable in the following format: player - age:AA wickets:BBB Inputs: player_p - variable to be printed */ }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!