Before the Lab
Study in the slides the material related to pointer to functions..
Step 1. Setting up Your Environment
Copy your lab files and enter the appropriate directories.
$ cd$ cd cs240$ tar -xvf /homes/cs240/lab8-ptr-to-funcs/lab8-src.tar$ cd lab8-src
Step 2. Pointer to functions Write a Sorting Function to Sort any Type of Array
Open the file mysort.c . In there you will implement the function
1 | void mysort( int n, // Number of elements |
This function takes an array of any type, the number n of elements, the elementSize, a comparison function compFunc and a flag ascending and it will sort the array passed using bubble sort or any sorting algorithm of your choice. You will also find there information of what this function should do.
To test your implementation type make and run test_mysort test1 to test_mysort test5 or type testall. IMPORTANT: You will need to modify test_mysort.c to fix compareStudentByGrade() needed for test3.
Step 3. Turning In your Project
Follow these instructions to turn in lab8:
Login to and type
cd cs240turnin -c cs240 -v -p lab8 lab8-src