From e83cd7b74ec89c4bf289575acab802caf0915695 Mon Sep 17 00:00:00 2001 From: Florian Baeseler Date: Mon, 5 Feb 2024 09:41:28 +0100 Subject: [PATCH] =?UTF-8?q?refactoring:=20Auslagerung=20von=20gr=C3=B6?= =?UTF-8?q?=C3=9Fenberechnung=20des=20arrays?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/test/results/test_casualQuiz.pass | 2 +- build/test/results/test_quizduell.pass | 2 +- build/test/results/test_timequiz.pass | 2 +- build/test/results/test_wwm.pass | 2 +- src/casualQuiz.c | 9 +++++---- src/casualQuiz.h | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/build/test/results/test_casualQuiz.pass b/build/test/results/test_casualQuiz.pass index 978c671..bc982b5 100644 --- a/build/test/results/test_casualQuiz.pass +++ b/build/test/results/test_casualQuiz.pass @@ -11,4 +11,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.01849400000355672 +:time: 0.013279100006911904 diff --git a/build/test/results/test_quizduell.pass b/build/test/results/test_quizduell.pass index 0cbc1d0..94d2b9e 100644 --- a/build/test/results/test_quizduell.pass +++ b/build/test/results/test_quizduell.pass @@ -11,4 +11,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.01689270000497345 +:time: 0.013567399990279227 diff --git a/build/test/results/test_timequiz.pass b/build/test/results/test_timequiz.pass index 3374c50..d242d30 100644 --- a/build/test/results/test_timequiz.pass +++ b/build/test/results/test_timequiz.pass @@ -11,4 +11,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.016173199997865595 +:time: 0.01407669999753125 diff --git a/build/test/results/test_wwm.pass b/build/test/results/test_wwm.pass index f5ca489..5452494 100644 --- a/build/test/results/test_wwm.pass +++ b/build/test/results/test_wwm.pass @@ -11,4 +11,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.016555199996219017 +:time: 0.013050099980318919 diff --git a/src/casualQuiz.c b/src/casualQuiz.c index a073817..02112ca 100644 --- a/src/casualQuiz.c +++ b/src/casualQuiz.c @@ -18,12 +18,13 @@ void casualQuiz() { }; int easy_richtigeAntworten[] = { 3,4}; // int, um die jeweils richtige antwort zu zeigen - activePlaying(easy_fragen, *easy_antworten, easy_richtigeAntworten); + int length_frag_array = sizeof(easy_richtigeAntworten)/sizeof(int); + activePlaying(easy_fragen, *easy_antworten, easy_richtigeAntworten, length_frag_array); return; } -void activePlaying(char *fragen[], char *antworten[], int richtige_antwort[]){ - int length = sizeof(richtige_antwort)/sizeof(int); - for (int i = 0; i < length; i++){ +void activePlaying(char *fragen[], char *antworten[], int richtige_antwort[], int size ){ + + for (int i = 0; i < size; i++){ printf(" %s\n1) %s\n2) %s\n3) %s\n4) %s\n %d\n", fragen[i], antworten[4 * i + 0], antworten[4 * i + 1], antworten[4 * i + 2], antworten[4 * i + 3], richtige_antwort[i]); } } diff --git a/src/casualQuiz.h b/src/casualQuiz.h index dcbd690..6c4d3ab 100644 --- a/src/casualQuiz.h +++ b/src/casualQuiz.h @@ -2,7 +2,7 @@ #define CASUALQUIZ_H void casualQuiz(); -void activePlaying(char *fragen[], char *antworten[], int richtige_antwort[]); +void activePlaying(char *fragen[], char *antworten[], int richtige_antwort[], int size); #endif // ende CASUALQUIZ_H