i wrote this to begin learning heap sort algorithm(i know this doesn't sort anything) but everytime i complile the program crashes and i get the error "variable arr was corrupted" anyone can explain me why ?
1 2 3 4 5 6 7 8 9 10 11 12 13 14
int main(){
srand(time(NULL));
intconst size = 10;
int arr[size];
for (int i = 0; i < size; i++)arr[i] = rand() % 40 + 1;
//print(arr, size);
complete(arr, size);
}
void complete(int arr[],int size){
for (int i = size; i>1; i--){
swap(arr[1], arr[i]);
}
}