Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!