I want to move the array in another function (type void), to change the value of the array, but every times i have got an error under gcc
I have those following rules:
- in this exercise it's forbidden to use global variable,
- We want to move the array by reference and not use pointers:
.
#include <stdio.h>
typedef enum {F=0,T=1} Mat;
//==========================//
void unknown(Mat b[][][]){
b[0][0][0]=7;
printf("%d\n",b[0][0][0]);
}
//=========================//
int main(void){
Mat b[2][2][2];
b[0][0][0]=1;
printf("%d\n",b[0][0][0]); //before the unknown
uknown(b);
printf("%d\n",b[0][0][0]); //after unknown
return 0;
}
I have the following error:
test.c:7:18: error: array type has incomplete element type ‘Mat[] {aka enum []}’ void unknown(Mat b[][][]){ ^ test.c: In function ‘main’: test.c:21:9: error: type of formal parameter 1 is incomplete unknown(b); ^
The question is : I need to change the value of the array, not in main, but in the function void unknown, and check in the main (after having change in void unknown values of array Mat b) if this array change this value by reference, what's wrong ? and what do I need to change inside the code ?
(my gcc version: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609)