Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C code !! #include #include #include #define MAX 1000 //Do not edit this macro. typedef struct{ int film_id; char title[255]; char description[1023]; unsigned int release_year;

C code !!

#include  #include  #include  #define MAX 1000 //Do not edit this macro. typedef struct{ int film_id; char title[255]; char description[1023]; unsigned int release_year; char rental_duration; float rental_rate; unsigned char length; float replacement_cost; char rating[10]; char last_update[30]; } RECORD_t, *RECORD; //Do not edit this struct. /* DECLARE YOUR FUNCTION PROTOTYPES HERE */ /* DECLARE YOUR FUNCTION PROTOTYPES HERE */ /* DECLARE YOUR FUNCTION PROTOTYPES HERE */ int main(){ RECORD rec = (RECORD)malloc(sizeof(RECORD_t)*MAX); //Do not edit this line. FILE *file = fopen("data.txt", "rb"); //Do not edit this line. if (file == NULL) { //Do not edit this line. printf("Cannot open the file. "); //Do not edit this line. exit(0); //Do not edit this line. } //Do not edit this line. fread(rec, sizeof(RECORD_t)*MAX, 1, file); //Do not edit this line. fclose(file); //Do not edit this line. /**************************/ /* Your code starts here. */ /**************************/ //The following is a hint to access the rec array in memory. printf("ID: %d ", rec[189].film_id); printf("TITLE: %s ", rec[189].title); printf("DESCRIPTION: %s ", rec[189].description); printf("RELEASE YEAR: %d ", rec[189].release_year); printf("RENTAL DURATION: %d ", rec[189].rental_duration); printf("RENTAL RATE: %f ", rec[189].rental_rate); printf("REPLACEMENT COST: %f ", rec[189].replacement_cost); printf("RATING: %s ", rec[189].rating); printf("LAST UPDATE: %s ", rec[189].last_update); //... /**************************/ /* Your code ends here. */ /**************************/ file = fopen("data.txt", "wb"); //Do not edit this line. fwrite(rec, sizeof(RECORD_t)*MAX, 1, file); //Do not edit this line. fclose(file); //Do not edit this line. free(rec); //Do not edit this line. return 1; //Do not edit this line. } /* IMPLEMENT YOUR FUNCTIONS HERE */ /* IMPLEMENT YOUR FUNCTIONS HERE */ /* IMPLEMENT YOUR FUNCTIONS HERE */ 

Make sure that film.c and data.txt are in the same folder.

1. Compile, run, and observe how film.c.

2. You are expected to engineer the functions: list, find, update, and sort.

3. Your performance will be graded with respect to your sort function. So, youd better start from the sort function.

4. The scope of these functions is up to your imagination and talent.

5. The assessment will be made with respect to the quality of your program. So handle as much exceptions as possible.

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

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions

Question

Can workers be trained in ethics? How? Defend your answer.

Answered: 1 week ago