Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago