From 3038343416ea1b6751cbd74fa2693e3e4b06c5c2 Mon Sep 17 00:00:00 2001 From: fdai7754 Date: Sun, 4 Feb 2024 19:45:05 +0100 Subject: [PATCH] integer overflow bei hohem alter gefixt --- src/ageinseconds.c | 6 +++--- src/ageinseconds.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ageinseconds.c b/src/ageinseconds.c index 4bc3512..f04746c 100644 --- a/src/ageinseconds.c +++ b/src/ageinseconds.c @@ -1,8 +1,8 @@ #include #include "ageinseconds.h" -int sekunden(int jahre) { - int erg = jahre * 31536000; +float sekunden(float jahre) { + float erg = jahre * 31536000; return erg; } @@ -73,7 +73,7 @@ int run_ageinseconds() { printf("Dein Alter: "); scanf("%d", &age); printf("-------------------------------------------------"); - printf("\nDu bist: %d Sekunden alt", sekunden(age)); + printf("\nDu bist: %0.f Sekunden alt", sekunden(age)); printf("\n-------------------------------------------------"); printf("\nDas sind %d in Minuten und %d in Stunden", minuten(age), stunden(age)); printf("\n-------------------------------------------------\n"); diff --git a/src/ageinseconds.h b/src/ageinseconds.h index 2b7a006..a951506 100644 --- a/src/ageinseconds.h +++ b/src/ageinseconds.h @@ -1,7 +1,7 @@ #ifndef AGEINSECONDS_H #define AGEINSECONDS_H -int sekunden(int jahre); +float sekunden(float jahre); int minuten(int jahre); int stunden(int jahre);