#include <stdio.h>
#include <stdlib.h>

typedef enum {
	INT, FLOAT, DOUBLE
} Type;

void initMat(Type type, int matSize, void **matA, void **matB, void **matC){
	switch(type) {
	case INT :
		*matA = malloc(matSize * sizeof(int*));
		*matB = malloc(matSize * sizeof(int*));
		*matC = malloc(matSize * sizeof(int*));
		int **matA_i = *matA;
		int **matB_i = *matB;
		int **matC_i = *matC;
		
		for (int i = 0; i < matSize; i++) {
			matA_i[i] = malloc(matSize * sizeof(int));
			matB_i[i] = malloc(matSize * sizeof(int));
			matC_i[i] = malloc(matSize * sizeof(int));
			for (int j = 0; j < matSize; j++) {
				matA_i[i][j] = rand() % 11;
				matB_i[i][j] = rand() % 11;
				matC_i[i][j] = 0;
			}
		}
		break;

	case FLOAT :
	case DOUBLE :
		//not yet
		*matA = NULL; *matB = NULL; *matC = NULL;
		break;

	default :
		printf("Invalid case.\n" );
	}
}

void displayMat(Type type, int matSize, void *matA){
	switch(type){
	case INT:
	{
		int **mat = matA;
		for(int i = 0; i < matSize; ++i){
			for(int j = 0; j < matSize; ++j){
				if(j)
					putchar(' ');
				printf("%d", mat[i][j]);
			}
			putchar('\n');
		}
	}
		break;
	default:
		printf("not yet\n");
	}
}

int main(void){
	Type type = INT;
	int size = 0;
	void *matA, *matB, *matC;

	int sizes[6] = {3, 4, 5};
	int matSize = sizes[size];
	printf("The selected matrix size is: %d.\n", matSize);

	initMat(type, matSize, &matA, &matB, &matC);

	displayMat(type, matSize, matA);
	//deallocate mat

}