Hi, I'm trying to write a minesweeper C code, this is how I started. I sadly can't figure out how to pass the field array to the create_field function. I've tried pointers,&,void brackets,no brackets,one void bracket and one with a dimension,and more, but the compiler returns lots of errors, such as this thing is neither a pointer nor an array nor an integer, or segmentation fault, or expected declaration before some input or bracket...I honestly can't see the error, thanks in advance!
P.S. I first created the field directly in the main() and then it worked.In order to make the program more elegant to see, or at least the main() more concise, I tried to subdivide it in several functions, of which this is the second, and the first problematic.
Code:#include<stdio.h> #include<time.h> #include<stdlib.h> main() { int A,B,mines; // rows and columns and number of mines askNumbers(&A,&B,&mines); int field[A][B]; create_field(A,B,mines, FIELD????); // how is this to be written? ... } void create_field(P,Q,mines,FIELD??) { // same question int i,j; srand(time(NULL)); for (i=0; i<P; i++) for (j=0; j<Q; j++) field[i][j] = 0; // unmined field do { for (i=0; i<P; i++) for (j=0; j<Q; j++) if (0==rand() && mines && 9!=field[i][j]) { field[i][j] = 9; // puts mines mines--; } } while (mines); }