Our professor at school gave us a "simple" programm task in C.
We should create a 2D Array, fill it with random numbers and give it to another function. This function should give out the 2D-Array.
The problem is: How do i hand over the 2D Array?
Also i have a problem by calling the function. I Included the .h file, but it always give errors.
#include <stdio.h>
#include <stdlib.h>
#include "ShowMatrix.h"
#define W1 10
#define W2 10
int main(void) {
int a,b;
int array[W1][W2];
for(a = 0; a < W1; ++a)
{
for(b=0; b<W2; ++b)
{
array[a][b] = rand() %10;
}
}
ShowMatrix(array[][W2], W1, W2);
return EXIT_SUCCESS;
}
The function which i want to call:
void ShowMatrix(int array[][10], int W1, int W2)
{
int a,b;
for(a = 0; a < W1; ++a)
{
for(b=0; b<W2; ++b)
{
printf("Inhalt von Array[%d][%d] ",a,b);
printf("ist: %d \n", array[a][b]);
}
}
}
Header part of the func:
#ifndef SHOWMATRIX_H_
#define SHOWMATRIX_H_
void ShowMatrix(int array[][], int W1, int W2);
#endif /* SHOWMATRIX_H_ */