Corona688 was great in helping me learn how to create arrays that hold other two dimensional array here. Unfortunately I didn't think ask about how to implement or call them. Basically, I'm trying to call an array of two-dimensional arrays like this:
declaration:
int (*side_one[MATRIX][MATRIX])[MATRIX] = { { white_l1, white_l2, white_l3 }, { white_m1, white_m2, white_m3 }, { white_r1, white_r2, white_r3 } };
call:
fillit((*side_one[MATRIX][MATRIX])[MATRIX]);
gcc warnings:
gcc -O4 test.c -o test -s
test.c: In function �fillit':
test.c:63:16: warning: assignment to �int *' from �int' makes pointer from integer without a cast [-Wint-conversion]
*side[t] = randval;
^
test.c: In function �main':
test.c:457:40: warning: passing argument 1 of �fillit' makes pointer from integer without a cast [-Wint-conversion]
fillit((*side_one[MATRIX][MATRIX])[MATRIX]);
~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
test.c:53:19: note: expected �int * (*)[1000][1000]' but argument is of type �int'
void fillit(int *(side[MATRIX][MATRIX])[MATRIX]){
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I've tried changing the argument in this function, how I call the function, and a lot of things, but no luck. Here is the function the function call goes to:
void fillit(int *(side[MATRIX][MATRIX])[MATRIX]){
int r, s, t, randval;
for (r = 0; side[r] != 0; r++){
for (s = 0; s < MATRIX; s++){
FILE *f;
for (t = 0; t < MATRIX; t++) {
f = fopen("/dev/urandom", "r");
fread(&side, sizeof(randval), 1, f);
if (side[t] != NULL){
*side[t] = randval;
}
fclose(f);
}
}
}
}
I'm sure the loops in the function are wrong. Sure it can probably be done in less than 3 loops. I won't be mad to get suggestions on those, but right now I'm just trying to pass the argument correctly.
Any advice much appreciated.