Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in C 1 0 . 1 1 LAB: Movie show time display Write a program that reads movie data from a CSV ( comma separated
in C
LAB: Movie show time display
Write a program that reads movie data from a CSV comma separated values file and output the data in a formatted table. The program first reads the name of the CSV file from the user. The program then reads the CSV file and outputs the contents according to the following requirements:
Each row contains the title, rating, and all showtimes of a unique movie.
A space is placed before and after each vertical separator in each row.
Column displays the movie titles and is left justified with a minimum of characters.
If the movie title has more than characters, output the first characters only.
Column displays the movie ratings and is right justified with a minimum of characters.
Column displays all the showtimes of the same movie, separated by a space.
Each row of the CSV file contains the showtime, title, and rating of a movie. Assume data of the same movie are grouped in consecutive rows.
Hints: Use the fgets function to read each line of the input text file. When extracting texts between the commas, copy the texts characterbycharacter until a comma is reached. A string always ends with a null character
Ex: If the input of the program is:
movies.csv
and the contents of movies.csv are:
:Wonders of the World,G
:Wonders of the World,G
:Journey to Space PG
:Buffalo Bill And The Indians or Sitting Bull's History Lesson,PG
:Buffalo Bill And The Indians or Sitting Bull's History Lesson,PG
:Buffalo Bill And The Indians or Sitting Bull's History Lesson,PG
:Adventures of Lewis and Clark,PG
:Adventures of Lewis and Clark,PG
:Halloween,R
the output of the program is:
Wonders of the World G ::
Journey to Space PG:
Buffalo Bill And The Indians or Sitting Bull PG :::
Adventures of Lewis and Clark PG::
Halloween R :
Output differs. See highlights below.
Special character legend
Input
movies.csv
Your output
Wonders of the World G ::
Journey to Space PG:
Buffalo Bill And The Indians or Sitting Bull PG :
Buffalo Bill And The Indians or Sitting Bull PG :
Buffalo Bill And The Indians or Sitting Bull PG :
Adventures of Lewis and Clark PG::
Halloween R :
Expected output
Wonders of the World G ::
Journey to Space PG:
Buffalo Bill And The Indians or Sitting Bull PG :::
Adventures of Lewis and Clark PG::
Halloween R :
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started