I am trying to implement timing on this program and cannot do it. Where am I wrong at? #include "stdio.h" #include "stdlib.h" #include "time.h" void swap(int *x, int *y) { if (x == y) return; *x ^= *y; *y ^= *x; *x ^= *y; } void cocktailSort(int *a, size_t n) { while (1) { char flag; size_t start[2] = {1, n - 1}, end[2] = {n, 0}, inc[2] = {1, -1}; for (int it = 0; it < 2; it++) { flag = 1; for (int i = start[it]; i != end[it]; i += inc[it]) if (a[i - 1] > a[i]) { swap(a + i - 1, a + i); flag = 0; } if (flag) return; } } } int main() { int array[] = {5, -1, 101, -4, 0, 1, 8, 6, 2, 3}; size_t n = sizeof(array) / sizeof(array[0]); printf("Original Array: \n"); for (int i = 0; i < n; i++) printf("%d%s", array[i], i == n - 1 ? " \n" : " "); printf("\nSorted Array: \n"); cocktailSort(array, n); for (int i = 0; i < n; ++i) printf("%d ", array[i]); return 0; } void timeAllSorts() { printf("All Times in milliseconds.\n"); printf("| %7s | %10s |\n", "Size", "Cocktail"); int size = 8; while (size <= 131072) { double c = timeASingleSort(cocktailSort, size); printf("| %7d | %10.4f |\n", size, c); size = size * 2; } } double timeASingleSort(void (*func)(int *, int), int size) { int *T = malloc(size * sizeof(int)); for (int i = 0; i < size; i++) { T[i] = rand() % (size * 4); } double before = (double)clock(); func(T, size); double after = (double)clock(); free(T); return (after - before) / (CLOCKS_PER_SEC / 1000); }.