First of all, you don't include the source files into one another, you compile and link them together to form the binary.
That said, the actual problem is in the code you did not show (multiplication.h
file), but from the error message we can see
void print(int arr[][]);
is not a valid syntax. You can only leave the outer(-most) index as empty, all other index(es) must have a proper value. Something like
void print(int arr[ ][10]);
^^---------- inner index
^^^------------- outer index
or, for more dimensions
void print(int arr[ ][5][10][15]);
The analogy behind this is, for function declarators,
"A declaration of a parameter as ''array of type'' shall be adjusted to ''qualified pointer to type'',...."
So, to have that adjustment, the type should be known to compiler at compile-time.
In case of a declaration like
void print(int arr[][10]);
the type is int[10]
, but if a syntax like
void print(int arr[][]);
is allowed , the type cannot be known. Hence the error.
Other issues: You seem to have many other issues, like
The function definition is
int mulitpication(int num){ // returning an int
but actually you do
return arr; //where arr is an array of size int[num][num], defined locally
this is invalid because of two things
- an
int
and an int[num][num]
are not the same type.
- the scope of a VLA i.e.,
arr
is limited to the function block, you cannot have the array return the address to the caller and expect something meaningful as the returned address will not be valid anymore.
I believe, you're better off using allocated memory (malloc()
and family) and keeping track of your index/ count of elements manually.