pointers and dynamic arrays
I'm having some trouble with poitners and dynamic arrays (a matrix).
Given this function I have a few questions.
void func(int* mat, int rows, int columns, char* out)
{
...
}
My first question is in main, how is a matrix defined that can be sent
to this function?
I can do it like:
int** matrix;
matrix = new int*[numRows];
for(int i=0; i< numRows; i++)
matrix[i] = new int[numColumns];
and by sending func(matrix,numRows, numColumns, out). But the only
way I can get it to accept this is by changing the first argument to
accept int** instead of int*. It has to accept int* so I'm not quite
sure how to declare a matrix in main.
My next question is how can I set an element of the matrix to a
location of the char* array?
I can easily use cout<<mat[3][3]; in the func and it'll output that
certain element on to the screen, but I can't get it to go to an
element in the character array.
I know this would be a lot easier to do this with out pointers and
just using arrays and not poitners to arrays so don't tell me that...
Thanks