First few parts of code:
typedef struct
{
double sr, med;
int **t;
}wynik;
wynik calc(int *t[], int size)
{
int i, *niep = NULL, j = 0, k = 1, sum = 0;
int *sorted = (int*)malloc(size*sizeof(int));
wynik out;
//coping, sorting
for (i = 0; i < size; i++)
sorted[i] = (*t)[i];
qsort(sorted, size, sizeof (**t), cmp);
out.t = &sorted;
...
return out;
}
then in main():
wynik get = calc(&tab, tab_size);
Using debugger I discovered that in calc() out.t points to an array, but in main() get.t points to some weird things. How to fix it?