Microsoft Word - AU 2020 CSE2421 Lab3 AU 2020 CSE 2421 LAB 3 Assigned: Wednesday, September 16th Early Due Date: Wednesday, September 23rd by noon Due: Thursday, September24th, by 11:30 p.m....

Please help with this project. Main included I also have makefile. We use Linux


Microsoft Word - AU 2020 CSE2421 Lab3 AU 2020 CSE 2421 LAB 3 Assigned: Wednesday, September 16th Early Due Date: Wednesday, September 23rd by noon Due: Thursday, September24th, by 11:30 p.m. Objectives: ∙ Pointers ∙ Multiple Levels of indirection ∙ Dynamic memory allocation ∙ Functions ∙ Arrays (dynamically allocated) ∙ Character Strings REMINDERS and GRADING CRITERIA:  This is an individual lab.  Waiting until the day this lab is due to start working on it, would be an unbelievably bad idea.  Effort has been made to insure that this lab description is complete and consistent. That does not mean that you will not find errors or inconsistency. If you do, please ask for clarification.  Every lab requires a Readme file (for this lab, it should be called lab3Readme – use this name. This file should include the following: ∙ Required Header: BY SUBMITTING THIS FILE TO CARMEN, I CERTIFY THAT I HAVE STRICTLY ADHERED TO THE TENURES OF THE OHIO STATE UNIVERSITY’S ACADEMIC INTEGRITY POLICY WITH RESPECT TO THIS ASSIGNMENT. THIS IS THE README FILE FOR LAB 3. ∙ Your name ∙ Total amount of time (effort) it took for you to complete the lab ∙ Short description of any concerns, interesting problems or discoveries encountered, or comments in general about the contents of the lab ∙ Describe, with 4-5 sentences, how you used gdb to find a bug in your program while debugging it. Or, if you had no bugs in your program, how you used gdb to verify that your program was working correctly. Include how you set breakpoints, variables you printed out, what values they had, what you found that enabled you to fix the bug.  You should aim to always hand an assignment in on time or early. If you are late (even by a minute – or heaven forbid, less than a minute late), you will receive 75% of your earned points for the designated grade as long as the assignment is submitted by 11:30 pm the following day, based on the due date given above. If you are more than 24 hours late, you will receive a zero for the assignment and your assignment will not be graded at all.  Any lab submitted that does not compile – without errors or warnings - and run WILL RECEIVE AN AUTOMATIC GRADE OF ZERO. No exceptions will be made for this rule - to achieve even a single point on a lab, your code must minimally build (compile to an executable without errors or warnings) on stdlinux and execute on stdlinux without crashing, the gcc command must use the –ansi and -pedantic options. Since a Makefile is required for this lab, you must create the appropriate compile statements to create a lab3main.o, readtitles.o, get_title.o, getfavorites.o, savedata.o, and free_dmem.o files, which would then create a lab3 executable. Graders will be downloading your lab3.zip file from Carmen, unzipping it, and then executing make from a linux command line prompt. Your program must compile –without errors or warnings – via commands within the Makefile. Given valid input, your program must also run without having a seg fault or other abnormal termination.  You are welcome to do more than what is required by the assignment as long as it is clear what you are doing and it does not interfere with the mandatory requirements. LAB DESCRIPTION BOOK LIST WITH FAVORITES (100%) Mandatory filenames: lab3main.c readtitles.c get_title.c getfavorites.c savedata.c free_dmem.c Mandatory executable name: lab3 PROBLEM: The user of your program will use it to create a list of books s/he had read, and then your program will create a subset of this list as a favorites list. You will not know how many books the user wishes to include on the list until the program gets its first input. After the user has finished entering all of the books titles, you must prompt the user for a subset of the book titles to put on a “favorites” list. You will want to review Slide Deck 13, slides 47 through 53 to help you visualize how the data should be stored. You must use pointers within this project such that you have one array of char * that contains all of the book titles and an array of char ** for favorites. The third item this program does is ask the user whether s/he want to store a copy of their information to a file on disk. If so, you program will ask for a file name and store the information within the file in the format shown in the example below. 1. First, you must prompt the user to enter the number of books titles they plan to enter. The user will enter an integer greater than or equal to 1 to indicate the number of book titles. (NOTE: Make a point to test your program to ensure entering just 1 book title works.) 2. You must dynamically allocate memory for the titles array, then dynamically allocate enough memory to hold each individual book title as each book title is read in. You can assume that there will be no book title with more than 60 characters. Remember that all character strings in C are null terminated and that you have to allocate space in your string for that null character, in addition to the length of the string you wish to have. Also realize that you won’t know how many of the 60 characters the book title will fill until after you read the title. 3. You must then prompt the user to enter each book title on a separate line. You must assume that each book title could contain more than one word and will be separated by a newline character from the next book title. You can assume that the user will enter the input in this format, so you do not need to check to make sure that the format of the input meets this description, and you do not need to reject input which is not properly formatted. You can also assume that the user’s input is correct. If you do not completely understand this description jump to the bottom of this file and check out the example data. 4. You can assume that there will be no book title duplicates. 5. After reading in all the book titles, your program must print all of the book titles back out with a number next to each title. 6. You must then ask the user to pick how many books s/he wishes to put on their favorites list. The favorites list will consist of a subset (up through all books on the titles list) of the books on the titles list. 7. Once you have this number, you will have to dynamically allocate enough space for an array of 8- byte addresses for the favorites array. 8. The user will then specify by title number which books should be included on the favorites list. 9. Your program must then print out the books on the favorite list. 10. Next, your program must ask whether the user wishes to store in an ASCII file the information they have input. They indicate yes/no with 1 or 2. 11. If the user wishes to save the data, you must open a file and store the information in the file based on the format shown below, close the file, and then confirm to the user the data has been saved. 12. Prior to exiting the program, you must free() all dynamically allocated memory. You can determine whether you have managed to accomplish this with the valgrind tool. CONSTRAINTS: ∙ Source code files (.c files) submitted to Carmen as a part of this program must include the following at the top of the file: /* BY SUBMITTING THIS FILE TO CARMEN, I CERTIFY THAT I HAVE STRICTLY ADHERED TO THE TENURES OF THE OHIO STATE UNIVERSITY’S ACADEMIC INTEGRITY POLICY WITH RESPECT TO THIS ASSIGNMENT. */ If you choose not to put the above comment in your file, you will receive no points for the lab.  You must comment your code  You must adhere to items 1-12 above.  You must create and submit a Makefile that will be used to create your .zip file and your executable, lab3. This Makefile must define at least each of the following targets: all, lab 3, lab3.zip, lab3main.o, readtitles.o, get_title.o, getfavorites.o, savedata.o, free_dmem.o, and clean. Creating this file at the beginning of your development process and using it as you work, will allow you to test your Makefile for proper operation.  Separate your code into different functions so that your main() is uncluttered and easy to understand. Pointers to your two arrays must be declared in your main() program. You must have a different function that is called from main() that performs each of the following tasks: 1. populates the titles array in a file called readtitles.c A. readtitles() must call a function called get_title() that reads a single book title from input. get_title() must reside in a file called get_title.c 2. populates the favorites array in a file called getfavorites.c 3. saves data
Sep 22, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here