I just started looking at this code and I will post somethings that I see. First I noticed this:
Code:
int **array = (int**)malloc(sizeof(int *) * 10);
for(i = 0; i < 10; i++){
array[i] = (int*)malloc(sizeof(int) * 4);
}
You said that the number of rows is determined at runtime yet this code will actually produce a 10 x 4 array every time. I don't know if you meant to do this or not.
When your code crashes do your receive any sort of error, like a segmentation fault?
Also, when calling qsort you must use a function pointer which means that you should change your qsort call from:
Code:
qsort(array, 10, sizeof(int) * 4, comp);
to:
Code:
qsort(array, 10, sizeof(array[0][0]), &comp);
Note that the change of the sizeof statement is not necessary just makes it easier to look back and realize what you are trying to do. That should get you started.