So I am working on Selection Sort for Find, Problem Set 3. When I use a function I made called swap to exchange the values, the array is not sorted. Function snippet:
if (min != i)
{
swap(values[i], values[min];
}
void swap(int a, int b)
{
int tmp = a;
a = b;
b = temp;
}
However when I remove the function and use code instead of the function, the array sorts. Snippet below:
if (min != i)
{
// swap value of i and with the minimum value.
int temp = values[i];
values[i] = values[min];
values[min] = temp;
}
Any idea why is this happening?
)
at the end ofswap(values[i], values[min];
. Could you also include the outcome/errors that the code gives?