From f2a6db5248f9ddca739d66b10df717a98ec35f7c Mon Sep 17 00:00:00 2001 From: Bohdan Yanchyk Date: Thu, 26 Mar 2020 22:12:49 +0000 Subject: [PATCH] =?UTF-8?q?Aktualizovat=20=E2=80=9Edu3/program.c=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du3/program.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/du3/program.c b/du3/program.c index 9338c82..3ab7607 100644 --- a/du3/program.c +++ b/du3/program.c @@ -4,16 +4,29 @@ #include #include +int ValidateTime(int hh , int mm , int ss) +{ + int ret=0; + + if(hh>24) ret=1; + if(mm>60) ret=1; + if(ss>60) ret=1; + + return ret; +} + int main() { char dateStr[11]; struct tm t; - - + int hour = 0, min = 0, secs = 0; fgets(dateStr, 11, stdin); - + sscanf(string , "%d:%d:%d" , &hour,&min,&secs); + if(!ValidateTime(hour,min,sec)){ + printf("Nespravny datum\n"); + } char* res = strptime(dateStr, "%d.%m.%Y", &t); if (res == NULL) { printf("error: can't parse date!\n");