14 Homework - C File Processing Part 1
14 Homework - C File Processing Part 1
Requirements
Instead of getting the movie data from the user, read the data from a plain text file.
1. Your code must use two functions (in addition to main) as described below.
2. The structure requirements are the same as Homework 08.
3. Your code must use a symbolic constant for the size of the array.
Requirements for Function 1 (Updated from Homework 13)
Purpose: This function opens and reads a plain text containing movie information and stores the
information in the appropriate position in the array. Then it closes the file.
Name: Give this function a meaningful name
Parameters: array of movie structures
Return value: None
Algorithm: 1. Open the file appropriately. Be sure to verify that the file opened successfully.
2. Then, within a loop that reads until the end of the file, use fscanf to read the movie
titles and numbers of downloads from a plain text file with the following format:
TitleOfMovie NumberOfDownloads
3. Note that the title of the movie will NOT have any spaces in it. Always set the last
element in the string to the null character, regardless of the length, although no
message is required.
4. All information should be stored directly into the appropriate location in the output
parameter.
5. Continue to read the movie information until the end of the file (EOF). DO not use
a counter-controlled loop for this!
6. After the loop, close the file.
Requirements for Function 2 (Same as Hmwk 13, unless you added the extra credit)
Purpose: This function displays the contents of the movie array.
Name: Give this function a meaningful name
5) BEST PRACTICES
Follow best practices in C programming. These include, but are not limited to, the following:
Appropriate use of white space and alignment
Meaningful variable names and appropriate naming conventions
Points will be deducted for sloppy code that is hard to read, even if it works, so pay attention to
these details.
6) SUBMIT ALL FILES BEFORE THE DUE DATE
See the due date for this assignment on the course calendar in Canvas and review the submission
requirements below.
7) ALL SUBMISSIONS MUST BE YOUR OWN WORK
Review the syllabus regarding plagiarism and the Joliet Junior College Academic Honor Code.
BY SUBMITTING ANY ASSIGNMENT, YOU ARE STATING THAT YOUR SUBMISSION IS YOUR OWN WORK
AND IS NOT PLAGIARIZED IN ANY FORM.
Submission
Submit your C source code file with the .c file extension to the drop box.
I will not accept links to online storage. You must submit the actual file. Do not submit an entire IDE
project.