The array gets sorted inside the sort function but the haystack doesn't change. How do I pass haystack by reference without changing the function prototype?
void sort(int values[], int n)
{
int count[MAX_VALUE] = { }; // initialise the range and result arrays
int result[n];
for(int i = 0; i < n; i++)
{
result[i] = 0;
count[values[i]]++; // count the values array
}
for(int i = 1; i < MAX_VALUE; i++)
{
count[i] = count[i] + count[i-1]; // add consecutive elements in the count array
}
for(int i = 0; i < n; i++)
{
result[count[values[i]] - 1] = values[i];
count[values[i]]--;
}
values = result;
return;
}