Aktualizovat „du3/program.c“
This commit is contained in:
parent
53a8f29c91
commit
f2a6db5248
@ -4,16 +4,29 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
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");
|
||||
|
Loading…
Reference in New Issue
Block a user