When compiling I get these errors:
Code:
sort.c:21error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âintâ
sort.c:46: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before â{â to ken
I was thinking it had something to do with the way I passed my dynamically allocated array to my function, but i cant think of any other way to do it. ive tried using *a, and *a[]...any suggestions?
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void quick_sort(int **a, int left, int right)
void swap(int **a, int i, int j)
int main (){
int number = 0;
printf("How many entries in the sort array?\n");
scanf( "%d", &number);
int *a = malloc(sizeof(int)*number);
int j = 0;
for( j = 0; j<number; j++){
a[j] = random()%100;
printf("%d\n", a[j]);
}
quick_sort(a, 0, number);
int d;
for(d=0; d<number;d++){
printf("%d\n", a[d]);
}
return 0;
}
void swap(int **a, int i, int j){
int temp;
temp = a[i];
a[j] = a[i];
a[j] = temp;
}
void insertion_sort(int **a, int n) {
int k;
for (k = 1; k < n; ++k) {
int key = a[k];
int i = k - 1;
while ((i >= 0) && (key < a[i])) {
a[i + 1] = a[i];
--i;
}
a[i + 1] = key;
}
}