Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _XOPEN_SOURCE
- #include <stdlib.h>
- #include <sys/stat.h>
- #include <stdio.h>
- #include <dirent.h>
- #include <time.h>
- #include <string.h>
- int main(int argc, char *argv []) {
- const int BUFF_SIZE = 18;
- char first_datetime[BUFF_SIZE];
- char second_datetime[BUFF_SIZE];
- fgets(first_datetime, BUFF_SIZE, stdin);
- struct tm first;
- memset(&first, 0, sizeof(first));
- strptime(first_datetime, "%Y-%m-%d %H:%M", &first);
- first.tm_isdst = -1;
- while(fgets(second_datetime, BUFF_SIZE, stdin) != NULL) {
- time_t first_time = mktime(&first);
- struct tm second;
- memset(&second, 0, sizeof(second));
- strptime(second_datetime, "%Y-%m-%d %H:%M", &second);
- second.tm_isdst = -1;
- time_t second_time = mktime(&second);
- double diff = difftime(second_time, first_time) / 60;
- printf("%ld\n", (long)diff);
- first = second;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement