Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*C PROGRAMMING* 5. Create a program that reads and writes creature data from and to a file using fread() and fwrite(). The creature data should

*C PROGRAMMING*

image text in transcribed

image text in transcribed

image text in transcribed

5. Create a program that reads and writes creature data from and to a file using fread() and fwrite(). The creature data should be represented as a struct with the following data members: Name CR AC HP Your program should include a menu that allows the user to list creature data or add a new creature. It should keep the user inside the program until they choose an option to exit. The struct should be defined using typedef. The data file should be passed as a command line argument. If the file cannot be opened for any reason, warn the user. If the file does not exist, create it. The program should check for invalid input in the menu. You can assume valid data will be entered for the creatures. Your output should match the output shown in the example below. Take care that the divider line is the same length as the name and that the entries have an empty line between them. After adding a creature, it should be written (append) to the file. Save your code as creature_db.c. Example Run - Adding Creatures 1. List Creatures 2. Add Creature 3. Exit > 2 Enter Name: Adult Blue Dragon Enter Challenge Rating: 16 Enter Armor Class: 19 Enter Hit Points: 225 Creature added! Example Run - List Creatures 1. List Creatures 2. Add Creature 3. Exit > 1 Beholder CR: 13 AC: 18 HP: 180 Adult Blue Dragon CR: 16 AC: 19 HP: 225

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

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions

Question

1. Signs and symbols of the map Briefly by box ?

Answered: 1 week ago

Question

Types of physical Maps?

Answered: 1 week ago

Question

Explain Intermediate term financing in detail.

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago