Write a code fragment to perform the specified task; remember, it's a fragment, so you don't have to show the #include statements or main(), but you should write proper C code that could be compiled and run correctly.
1. Write a function int* sortRemoveDuplicated(int input[5][2], int *num_unique_values); to sort a multi-dimensional integer array input of a fixed size 5 by 2, remove duplicated values, update num_unique_values and return the unique sorted values as an 1D array, which is dynamically allocated in the function.
Example
int input[5][2] = { {2, 3}, {2, 3}, {2, 3}, {1, 2}, {5, 4} };
int num_unique_values = 0;
int* output = sortRemoveDuplicated(input, &num_unique_values);
for (int i = 0; i < num_unique_values; ++i) printf("%d ", output[i]);
It should print 1 2 3 4 5.
2. Complete the below function bool readLine(FILE* fp, char** line, int* array_size); that reads a line from a file given by the file pointer fp, stores the line into the C string *line, and updates the array size array_size if the array size of *line has changed. Your implementation should meet the following requirements:
bool readLine(FILE* fp, char** line, int* array_size) {
// temp buffer, assuming a line has at most 1024 characters
char temp[1024];
if (fgets(temp, 1024, fp)) {
// TODO: temp contains the line, your tasks are:
// 1. Handle the dynamic memory allocation for *line,
// 2. Update *array_size if necessary
// 3. Copy values from temp to *line
// Note: line is a pointer to a c-string, when you
// allocate memory, think carefully which
// variable you need to use
// Write your code below
return true;
}
return false;
}