# is my swap function breaking my bubble sort implementation?

I'm trying to implement the bubble sort algorithm in , but it's not working! Pretty sure it's because of failure to swap. Been working on it for a while, with no success. Here's the relevant code:

``````/**
* Sorts array of n values.
*/
void sort(int values[], int n)
{
//iterates through the entire array. Stops 1 short of full array so that i+1 doesn't go past end (didn't work when it was n-1 either)
for (int i = 0; i < (n-2); i++) {
// if a value is greater than value after it...
if (values[i] > values[i+1]) {
// swap the values location ('&' is location)
swap(&values[i], &values[i+1]);

// testing to see if works
printf("value [%d] = %d\n", i, values[i]);
}
}

return;
}

// the '*' shows that dealing with location of a and b, not making a copy of them
void swap(int* a, int* b) {
// placeholder value
int temp;
temp = *a;
*a = *b;
*b = temp;
}
``````

Thanks in advance to anyone who takes a look!

``````for (int i = 0; i < (n-2); i++)