From 5f2056acb446e2868823074e0ece9c3a40c6b125 Mon Sep 17 00:00:00 2001 From: Benedikt Date: Tue, 11 Nov 2025 11:16:37 +0100 Subject: [PATCH] create fert --- matrix.c | 34 ++++++++++++++++++++++++++++++++-- matrix.h | 7 +++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/matrix.c b/matrix.c index 59aa506..0f5944d 100644 --- a/matrix.c +++ b/matrix.c @@ -1,17 +1,47 @@ #include #include #include "matrix.h" +#include // TODO Matrix-Funktionen implementieren ... ok Matrix createMatrix(unsigned int rows, unsigned int cols) { - + Matrix matrix; + + if (rows == 0 || cols == 0) + { + matrix.rows = 0; + matrix.cols =0; + matrix.data = NULL; + return matrix; + } + matrix.rows = rows; + matrix.cols = cols; + + matrix.data = (MatrixTyype *)malloc(rows * cols * sizeof(MatrixType)); + + if (matrix.data == NULL) + { + matrix.rows = 0; + matrix.cols = 0; + + return matrix; + } + + for (int i = 0; i