02-06-2004, 07:43 PM
Okay, this question isn't a problem I have, it's a complete blank I draw when trying to comprehend how it would be done...
I know how to use arrays and pointers in C. I'm very comfortable with them now:
That's a simple function that takes an array and prints it out.
Well, I have absolutely no idea how to use pointers with multdimensional arrays. My book just touches that lightly, but I don't understand.
So if I wanted to have a function that took a pointer to a multidimensional array (say, a map for a game), and fill that map with the correct signifigant values for tiles in the game...how would I do it?
I know how to use arrays and pointers in C. I'm very comfortable with them now:
Code:
#include <stdio.h>
void pass_array(int *array, int length);
int main() {
int array[3]={1,2,3};
pass_array(array,3); /* could be pass_array(&array[0]), too */
return 0;
}
void pass_array(int *array)
{
int i;
for (i=0; i<3; i++)
printf("%d",*(array+i)); /* could be array++ or array[i] as well */
}
Well, I have absolutely no idea how to use pointers with multdimensional arrays. My book just touches that lightly, but I don't understand.
So if I wanted to have a function that took a pointer to a multidimensional array (say, a map for a game), and fill that map with the correct signifigant values for tiles in the game...how would I do it?