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](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f32f0d88c10_32466f32f0cdfdc1.jpg)
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
Get step-by-step solutions from verified subject matter experts
