You need to call directly
forward(words, puzzle);
However, you have an error in your code: you forgot j++ in the read loop while reading words , so you overwrite words[0] and do not initialize other members of the array.
Also, in a real situation, you may need to choose the size of the array at runtime. An easy way to do this is to choose a large enough limit for the width and height and go with the 0x90 solution (you need a 30x20 puzzle, and you can easily handle it since you compiled with ROWS and COLS equal to, say, 1024).
A more complicated way would be to use malloc() (using pointers to pointers to characters) and dynamically allocate both arrays, limited by available memory; you then pass your measurements to the forward function.
int forward(char **words, char **puzzle, size_t w_w, size_t w_h, size_t p_w, size_t p_h) { }
However, the allocation part will be more complicated given the malloc() calls in cycles and the need to check its return value each time to catch the conditions of lack of memory; also in some scenarios you may want to free up memory (for example, to run repetitive puzzles), which will lead to further complexity.
LSerni
source share