So I have to write a program that sorts a 2d array and then returns it but I just found out you cant return an array from a function. I tried researching this but nothing fixes the problem. Any help is appreciated, thanks.
Below is the function I wrote to sort the vertical rows.
int vertSort(int matrix[][51], int size)
{
for(c=0;c<size;c++)
{
for(r=0;r<size-1;r++)
{
if(matrix[c][r]>matrix[c][r+1])
{
printf("Swap row %d column %d with row %d column %d", r, c, r, c)
int tmp=matrix[c][r];
matrix[c][r]=matrix[c][r+1];
matrix[c][r+1]=tmp;
}
}
}
return matrix;
}
for(r=0;r<size-1;r++)does not match with51in the signature; replacesizeby51or vice versa