Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Overview: In this assignment, you will create a collection of books using a Book struct: typedef struct { char * title; char * author; int

Overview:
In this assignment, you will create a collection of books using a Book struct:
typedef struct {
char *title; char *author;
int year;
3 Book;
Book *create_library (char *);
This function reads in book_list. txt (provided) and creates an array of 50 Book structs. It returns a pointer to this array.
void display books (Book *);
This function takes the pointer to the array of books, and prints them to the screen.
void reverse_books (Book *);
This function creates a reversed book list and returns a pointer to the reversed array.
save_to_file(FILE *, Book *);
This function saves the reversed list to a file.
You will need to pass the name of the file on the command line and pass it as an argument to create_library (). You are free to implement helper functions if you wish.
Compile your program using: gcc -Wall -pedantic library. c - std=c90-0 Library
To run the program: /library book_list.txt reversed list.txt
Example Run:
*************** Original Library ****
Title: To Kill a Mockingbird, Author: Harper Lee, Year: 1960
Title: 1984, Author: George Orwell, Year: 1949
*************** Reversed Library********
Title: Beloved, Athor Tani Morason, var 1987Now that you have your program displaying the output to the screen, add the save_to_file() functionality to have your program save the reversed list to a file called reversed_list. txt. The filename should be passed in on the command line when you run the program:
/library book_list.txt reversed list.txt
Note: the program should also run without the second filename provided, in which case it just wouldn't producethatfile. library.c file: typedef struct {
char *title;
char *author;
int year;
} Book;
Book *create_library(char *filename);
void display_books(Book *library);
Book *reverse_books(Book *library);
void save_to_file(char *filename, Book *library);
int main(){
/* create the library */
Book *library = create_library();
printf("*************** Original Library ***************
");
/* display the library onto the screen */
display_books(library);
/* Create a reversed library */
Book *reversed_library;
printf("
*************** Reversed Library ***************
");
display_books(reversed_library);
/* Save the reversed library to a file */
save_to_file();
}
Book *create_library(char *filename){
}
void display_books(Book *library){
}
Book *reverse_books(Book *library){
Book *reversed_library = malloc(50* sizeof(Book));
}
void save_to_file(char *filename, Book *library){
}
/*1245_66611*/ book.txt file:To Kill a Mockingbird, Harper Lee, 1960
1984, George Orwell, 1949
Pride and Prejudice, Jane Austen, 1813
The Great Gatsby, F. Scott Fitzgerald, 1925
Moby Dick, Herman Melville, 1851
War and Peace, Leo Tolstoy, 1869
The Catcher in the Rye, J.D. Salinger, 1951
The Lord of the Rings, J.R.R. Tolkien, 1954
Jane Eyre, Charlotte Bront,1847
The Hobbit, J.R.R. Tolkien, 1937
Animal Farm, George Orwell, 1945
Crime and Punishment, Fyodor Dostoevsky, 1866
The Brothers Karamazov, Fyodor Dostoevsky, 1880
Brave New World, Aldous Huxley, 1932
Wuthering Heights, Emily Bront,1847
Great Expectations, Charles Dickens, 1861
The Odyssey, Homer, -800
The Iliad, Homer, -750
Ulysses, James Joyce, 1922
Madame Bovary, Gustave Flaubert, 1857
The Divine Comedy, Dante Alighieri, 1320
The Count of Monte Cristo, Alexandre Dumas, 1844
Les Misrables, Victor Hugo, 1862
Anna Karenina, Leo Tolstoy, 1877
The Grapes of Wrath, John Steinbeck, 1939
One Hundred Years of Solitude, Gabriel Garcia Marquez, 1967
The Picture of Dorian Gray, Oscar Wilde, 1890
Fahrenheit 451, Ray Bradbury, 1953
Slaughterhouse-Five, Kurt Vonnegut, 1969
The Scarlet Letter, Nathaniel Hawthorne, 1850
Dracula, Bram Stoker, 1897
Frankenstein, Mary Shelley, 1818
Catch-22, Joseph Heller, 1961
The Sun Also Rises, Ernest Hemingway, 1926
East of Eden, John Steinbeck, 1952
The Old Man and the Sea, Ernest Hemingway, 1952
A Tale of Two Cities, Charles Dickens, 1859
The Adventures of Huckleberry Finn, Mark Twain, 1884
The Adventures of Tom Sawyer, Mark Twain, 1876
Mansfield Park, Jane Austen, 1814
Sense and Sensibility, Jane Austen, 1811
Emma, Jane Austen, 1815
Northanger Abbey, Jane Austen, 1817
Persuasion, Jane Austen, 1818
Heart of Darkness, Joseph Conrad, 1899
The Metamorphosis, Franz Kafka, 1915
The Trial, Franz Kafka, 1925
Invisible Man, Ralph Ellison, 1952
Beloved, Toni Morrison, 1987
Lolita, Vladimir Nabokov, 1955

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

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions

Question

Why must in-service training or on-the-job education be continuing?

Answered: 1 week ago