Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C language ! no JAVA 7.1.2 Preconditions You will have access to the classic horror short stories I Have No Mouth, And I Must Scream

C language ! no JAVAimage text in transcribed

7.1.2 Preconditions You will have access to the classic horror short stories I Have No Mouth, And I Must Scream by Harlan Ellison and The Shadow over Innsmouth by H. P. Lovecraft in ASCII text files (consider this your content warning if you decide to read them). You will create a struct for holding the simple contents of a book and provide a series of functions for initializing, manipulating, and destroying said books. Your book.h header file will contain forward definitions, struct definitions and typedefs, and any necessary library imports to ensure the proper operation of your functions. You must also write an accompanying book.c file contain- ing all of the matching function implementations. When you compile, you will need to include the source file in your command in order to ensure the functions exist during the linking process. You may include any additional helper functions as you see fit, although they will likely not be necessary. Since you are dealing with pointers, you will need to check all of your pointers to ensure they are not null when they are passed into your functions. Trying to perform operations on null pointers will lead to segmentation faults or other program crashes at run-time. Your book program must include the following structs (typedef-ed appropriately): Structure Name Fields Functionality Book (typedef Book) int characterCount Holds the total number of characters in the book's contents. int lineCount Holds the total number of lines in the book's contents. char **lines Holds all the lines of the book as strings. Your book program must include the following functions: Requirement Conditions Function Book* make_book(int) Input Parameters An integer representing the maximum number of lines your book can hold. Return value A pointer to an initialized Book. Notes An initialized book has no lines, but can hold up to the maximum provided. Character and line counts should be 0. Requirement Conditions Function void burn_book (Book*) Input Parameters A pointer to a Book. Return Value None. Notes This function should deallocate all of the lines in the Book, and then the Book itself. Requirement Conditions Function bool save_book (Book*, char*) Input Parameters A pointer to a Book and a string representing a file name. Return Value Return true if the book's contents were stored to a file successfully. Otherwise false. Notes This function should create or open a file based on the file name and write all of the current contents of the provided Book to that file one line at a time. Requirement Conditions Function bool fill book (Book*, char*) Input Parameters A pointer to a Book and a string representing a file name. Return Value Return true if the book's contents were read and stored successfully. Otherwise false. Notes This function should read from the file name provided and store each line in the provided Book. Requirement Conditions Function int edit_book (Book*, char*) Input Parameters A pointer to a Book and a string representing a word. Return Value An integer value that represents how many lines were removed from the book. Notes This function should remove every line from the Book which contains the provided word. Requirement Conditions Function void read book (Book*) Input Parameters A pointer to a Book. Return Value Notes This function should print the provided Book's content to stdout line-by-line. None

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

Step: 3

blur-text-image

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions