Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: C code help

  1. #1
    New to the CF scene
    Join Date
    Nov 2018
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    C code help

    Can someone help me code this in C...

    The file movielist.txt contains movie information (title, production company, release year, rating). Write a C program that
    a) Asks the user to enter the file that contains the movie database.
    b) reads movies from the file entered by the user and stores it in an array of type movie
    c) allows a user to search the movie database based on title or release year and
    d) is interactive (q to quit).

    1) Your program MUST use the following structure:
    typedef struct movie_s {
    char title[100]; //movie title
    char company[50]; //production company
    int year; //year release
    float rating; //out of 10
    }movie;

    2) Your program MUST use the following two user-defined functions:

    movie readMovie(FILE *inp); // read one movie from file pointed by inp
    void printMovie(movie *m); //print all attributes of a movie pointed by m

    Note: There is no need to use a linked list. The number of movies file does not exceed 100 => an array of type movie will work. You will not be penalized if you choose to use a linked list.

    Make sure you understand the sample code execution thoroughly before writing the code.

    Sample Code Execution: Red entered by a user

    Enter the movie database file: myMovies.txt
    The file does not exist.
    Enter the movie database file: movies.txt
    The file database was loaded successfully.

    Choose an option:
    1: Search by title
    2: Search by release year

    Enter your choice: 5

    Invalid choice

    Continue? (q to quit): y

    Choose an option:
    1: Search by title
    2: Search by release year

    Enter your choice: 1

    Enter movie title: Home
    NOT in database

    Continue? (q to quit): y

    Choose an option:
    1: Search by title
    2: Search by release year

    Enter your choice: 1

    Enter movie title: Minority Report
    Minority Report
    Cruise/Wagner Productions
    Year: 2002
    Rating: 8.10


    Continue? (q to quit): y

    Choose an option:
    1: Search by title
    2: Search by release year

    Enter your choice: 2

    Enter year release: 2004
    No movie with that year in the database

    Continue? (q to quit): q

  2. #2
    Regular Coder
    Join Date
    Oct 2015
    Posts
    413
    Thanks
    1
    Thanked 51 Times in 48 Posts


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •