Originally Posted by
Salem
> void sortList(int** table, int nrow)
So where is the information telling you that one row has 8 elements, and another row has 3 elements?
you initialize them from another function which i called it buildTable
Code:
int** buildTable (int* nrows){
int rowNum;
int colNum;
int** table;
int row;
printf("Enter the number of rows: ");
scanf("%d", &rowNum);
while(rowNum < MIN_ROW || rowNum > MAX_ROW)
{
printf("Invalid, enter a number of row between 1 and 10: ");
scanf("%d", &rowNum);
}
table = (int**) calloc(rowNum + 1, sizeof(int*));
for(row = 0; row < rowNum; row++)
{
printf("Enter the number of integer(s) in row %d: ", row+1);
scanf("%d", &colNum);
while(colNum < MIN_ENTRY || colNum > MAX_ENTRY)
{
printf("Invalid, enter the number between 1 and 15: ");
scanf("%d", &colNum);
}
table[row] = (int*) calloc(colNum + 1, sizeof(int));
table[row][0] = colNum;
}
table[row] = NULL;
*nrows = rowNum;
return table;
}//buildTable
and another function to fill in random integers to each row