Aktualizovat „du3/program.c“

This commit is contained in:
Bohdan Yanchyk 2020-03-26 22:12:49 +00:00
parent 53a8f29c91
commit f2a6db5248

View File

@ -4,16 +4,29 @@
#include <string.h> #include <string.h>
#include <time.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() int main()
{ {
char dateStr[11]; char dateStr[11];
struct tm t; struct tm t;
int hour = 0, min = 0, secs = 0;
fgets(dateStr, 11, stdin); 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); char* res = strptime(dateStr, "%d.%m.%Y", &t);
if (res == NULL) { if (res == NULL) {
printf("error: can't parse date!\n"); printf("error: can't parse date!\n");