Question: 5. [20 points] Write a function with the following signature: int sort_by_name (const char *filename); The file specified by filename contains the binary representation of

 5. [20 points] Write a function with the following signature: int

5. [20 points] Write a function with the following signature: int sort_by_name (const char *filename); The file specified by filename contains the binary representation of an array of structures of the following type. struct person f int char name [256] int char birthplace [256]; unique_ID; age; This structure's integer fields are stored in the same endianness as the machine that you are using to process the file. In other words, the data within the structure's fields will be stored in the file just as they would be in memory. Currently, the structures within the given file are ordered by their unique ID. Instead, we want to order them ASCIIbetically by name. The function sort_by name O must use mmap (2) and qsort(3) to read, sort, and rewrite the contents of the file. On success, the function should return 0. In case of an error, it should return -1. In either case, success or failure, the function should release any resources that it acquired

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!