Advertisement
FoxTuGa

LifeSecs

Sep 29th, 2011
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.51 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "timmings.h"
  4. #include <time.h>
  5. #include <conio.h>
  6.  
  7. int main() {
  8.     struct tagDATAS DActual, DNasc;
  9.     struct tagHORAS HActual, HNasc;
  10.     struct tm *today;
  11.     unsigned long long SegundosTotais;
  12.     int turn, temp;
  13.     char c;
  14.     time_t ltime;
  15.     turn = temp = 0;
  16.     while(TRUE) {
  17.         time(&ltime);
  18.         today =  localtime(&ltime);
  19.  
  20.         DActual.dia = today->tm_mday;
  21.         DActual.mes = today->tm_mon+1;
  22.         DActual.ano = today->tm_year+1900;
  23.         HActual.hora = today->tm_hour;
  24.         HActual.minutos = today->tm_min;
  25.         HActual.segundos = today->tm_sec;
  26.  
  27.         if( turn == 0 ) {
  28.             // Input + Validacao da Hora do Nascimento
  29.             printf("Indique <hh:mm:ss> Nasci: ");
  30.             scanf("%d:%d:%d", &HNasc.hora, &HNasc.minutos, &HNasc.segundos);
  31.             if( !ValidaHora(HNasc.segundos, HNasc.minutos, HNasc.hora) )
  32.                 return 0;
  33.  
  34.             // Input + Validacao da Data do Nascimento
  35.             printf("Indique <DD/MM/AA> Nasci: ");
  36.             scanf("%d/%d/%d", &DNasc.dia, &DNasc.mes, &DNasc.ano);
  37.             if( !ValidaData(DNasc.dia,DNasc.mes, DNasc.ano) )
  38.                 return 0;
  39.             turn = 1;
  40.         }
  41.  
  42.         SegundosTotais = ContaSegVida(HActual, HNasc, DActual, DNasc);
  43.         if( temp == 0 )
  44.             temp = SegundosTotais;
  45.  
  46.         if( temp != SegundosTotais ) {
  47.             system("cls");
  48.             printf("\n\n\t\tSegundos de Vida: %lld\n\n", SegundosTotais);
  49.             printf("\nClique 'S' para terminar\n\n");
  50.             temp = SegundosTotais;
  51.             printf("\n");
  52.         }
  53.         if( _kbhit() ) {
  54.             fflush(stdin);
  55.             c = getch();
  56.             if( c == 'S' || c == 's' )
  57.                 break;
  58.         }
  59.     }
  60.     return 0;
  61. }
  62.  
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement