Sorting 3D matrix (Segmentation Fault)

Hi! New problems come to me... the problem seems simple the solution... well can't seem to find it now and since people here seem very nice and helpy here it goes :D

I have a struct which is table it has a cell member which is a pointer to a pointer to a pointer of chars in other words a 3 dimensional dynamic array of chars... I use this as a table container so it is like a 2 dimensional array of strings. I tried writing a simple function to sort the table using the bubble sort algorithm to order (this is important) just the first column and starting on the second row (since the first row is reserved for the column header and shouldn't be sorted)

But at some point I'm getting a segmentation fault (programming under codeblocks 10.05 and gcc on windows I get a SIGSEV msg) lately I've been reading about this trying to find the problem... like NULL pointers and that kind of things but I don't seem to find what going wrong... here is the sorting function, I'm not sure if it is the problem so if you need some code about the table and the create_table routine I'm using etc... tell me!

Code:

`void sort_table(table *t){`

int i, j, order;

table tmp;

tmp = create_table("tmp", t->rows, t->cols);

i = 1;

order = 0;

while(order == 0){

for(j = 1; j < t->rows - i + 1; ++j){

order = 1;

if(strcmp(t->cell[j][0], t->cell[j+1][0]) > 0){

tmp.cell[j] = t->cell[j];

t->cell[j] = t->cell[j+1];

t->cell[j+1] = tmp.cell[j];

order = 0;

}

}

++i;

}

}

Thank you very much in advance!! ;)