F
finerrecliner
hey everyone
i'm trying to make a function that will return the length and width of
a dynamically allocated 2D array.
here's what i came up with to find width:
int findWidth(int** matrix)
{
int width = 0;
while(matrix[width][0] != NULL)
width++;
return width;
}
this doesnt work though. part of the problem is that my matrix has many
zeros. and i think this function treats those zeros as NULL, and doesnt
return the right value.
who has other ideas?
i'm trying to make a function that will return the length and width of
a dynamically allocated 2D array.
here's what i came up with to find width:
int findWidth(int** matrix)
{
int width = 0;
while(matrix[width][0] != NULL)
width++;
return width;
}
this doesnt work though. part of the problem is that my matrix has many
zeros. and i think this function treats those zeros as NULL, and doesnt
return the right value.
who has other ideas?