Having some serious problems wrapping my head around how to pass a 2D array to a function in C - pointers are not my strong point!
I need to have a function which takes a 2D array and generates random bits, so the result is an array of random binary strings.
Currently I have
#define pop_size 50
#define chrom_length 50
main() {
int population[pop_size][chrom_length];
init_pop(&population);
}
int init_pop(int *population[][]) {
for(i = 0; i < pop_size; i++) {
for(j = 0; j < chrom_length; j++) {
*population[i][j] = rand() % 2;
}
}
return 0;
}
Which gives me the compilation error of "error: array type has incomplete element type"
Any help appreciated here!