Question: in c Create a that contains the following fields: - (a char array of size 32) - (a char array of size 16) - hp

in c

in c Create a that contains the following fields: - (a chararray of size 32) - (a char array of size 16) -hp (an int) - (an int) This struct should be defined in

Create a that contains the following fields: - (a char array of size 32) - (a char array of size 16) - hp (an int) - (an int) This struct should be defined in a header file called monster. h. Make sure you include a header guard. In monster. c, implement a function named create_monster that prompts the user to enter the values for each field of the struct monster. The function should return a struct monster object. Additionally, create a function called print_monster that takes a as a parameter and prints the data in the following format: Name: name Type: type HP: hp Level: level Include the declarations for these functions in monster. h. Create a third file named test_add_monster. c that includes and tests your and function. Now that the monster is defined and we can add new entries in memory, we need to be able to save the data to a file. Create a function named that takes a and a FILE pointer as parameters. The function should write the as binary data. You can assume that the given pointer is already open for writing. Define this function in and include the declaration in Create a third file named that includes and tests your function by creating a monster with and saving it to a file. Make sure to open the file in append mode so that new entries will save to the end of the file. The next step is to load the data from the file into memory. Create a function named that takes a FILE pointer as a parameter. The function should read the next line from the file and return a object. You can assume that the given FILE pointer is already open for reading. Since this data is stored in a binary file, you will need to use the fread function to load the data. Since the data was written in the same order that it was read, you can use the same fread calls to load the data into a monster array. You can assume that the file contains less than 128 monster objects. We will also need a way to display the data after loading. Create a function named print_monsters that takes an array of struct monster objects and the number of elements in the array as parameters. It should print a table of the data in the following format: Namename1name2Typetype1type2HPhp1hp2Levellevel1level2 Create a file named that includes monster.h and tests your and functions by loading the data from the file and printing it to the screen

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!