Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include "timmings.h"
- #include <time.h>
- #include <conio.h>
- int main() {
- struct tagDATAS DActual, DNasc;
- struct tagHORAS HActual, HNasc;
- struct tm *today;
- unsigned long long SegundosTotais;
- int turn, temp;
- char c;
- time_t ltime;
- turn = temp = 0;
- while(TRUE) {
- time(<ime);
- today = localtime(<ime);
- DActual.dia = today->tm_mday;
- DActual.mes = today->tm_mon+1;
- DActual.ano = today->tm_year+1900;
- HActual.hora = today->tm_hour;
- HActual.minutos = today->tm_min;
- HActual.segundos = today->tm_sec;
- if( turn == 0 ) {
- // Input + Validacao da Hora do Nascimento
- printf("Indique <hh:mm:ss> Nasci: ");
- scanf("%d:%d:%d", &HNasc.hora, &HNasc.minutos, &HNasc.segundos);
- if( !ValidaHora(HNasc.segundos, HNasc.minutos, HNasc.hora) )
- return 0;
- // Input + Validacao da Data do Nascimento
- printf("Indique <DD/MM/AA> Nasci: ");
- scanf("%d/%d/%d", &DNasc.dia, &DNasc.mes, &DNasc.ano);
- if( !ValidaData(DNasc.dia,DNasc.mes, DNasc.ano) )
- return 0;
- turn = 1;
- }
- SegundosTotais = ContaSegVida(HActual, HNasc, DActual, DNasc);
- if( temp == 0 )
- temp = SegundosTotais;
- if( temp != SegundosTotais ) {
- system("cls");
- printf("\n\n\t\tSegundos de Vida: %lld\n\n", SegundosTotais);
- printf("\nClique 'S' para terminar\n\n");
- temp = SegundosTotais;
- printf("\n");
- }
- if( _kbhit() ) {
- fflush(stdin);
- c = getch();
- if( c == 'S' || c == 's' )
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement