So right after I do this swap function all the values in my array goes to -858993460. Why that number? I think it's the way I declare my array, but isn't A a pointer by declaring it that way? I'm trying to figure out why this is. well here's the code:
int* arrayCreate()//added mg
{
int a[] = { 3, 7, 4, 9, 5, 2 };
return a;
}
void Sort::Insert()
{
int t = 0;
//start clock
clock_t start = clock();
d = arrayCreate();
size = 6;
for (int i = 1; i< size; i++)
{
t = i;
while (((t - 1) >= 0) && (d[t] < d[t- 1]))
{
//Swap
Swap(d[t], d[t- 1]); // right after this call
//the debugger says values go to - 8e^8
t--;
}
}
}
void Sort::Swap(int& n1, int& n2)
{
int temp = n1;
n1 = n2;
n2 = temp;
}