Originally Posted by
zacs7
Doesn't matter, arrays are contiguous.
Code:
int test[][3] = {{3,5,1}, {5,2,3}, {19,14,5}};
qsort(test, sizeof(test) / sizeof(test[0][0]), sizeof(test[0][0]), myCompare);
Can also be written as,
Code:
int test[] = {3, 5, 1, 5, 2, 3, 19, 14, 5};
qsort(test, sizeof(test) / sizeof(test[0]), sizeof(test[0]), myCompare);
>I want to know what is the behaviour of this function, Why it is so giving unregular results???
You mean qsort()? It's not. Do a
man qsort if you want to know how it works.
Actually i think the results of that wouldnt be what he wants.
Lets say the data looks like this:
Code:
int test[][3] = {
{8, 2, 5},
{0, 7, 2},
{99, 5, 33}
};
I think the results would look like this:
Code:
int test[][3] = {
{0, 2, 2},
{5, 5, 7},
{8, 33, 99}
};
But he may want the results to look like this:
Code:
int test[][3] = {
{2, 5, 8},
{0, 2, 7},
{5, 33, 99}
};