Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********************************/
- /* Calendario.C */
- /* Autor: Luciana Ribeiro */
- /********************************/
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #define MINUTE 60
- struct HoursAndDates {
- int Hh,Mm,secunds,date,years,Month;
- };
- typedef struct HoursAndDates info;
- int main()
- {
- info *time_t= (info *) malloc(sizeof(info));
- if (time_t == NULL)
- {
- fprintf(stderr,"erro \n");
- exit( 0 );
- }
- time_t->Hh = 23;
- time_t->Mm = 59;
- time_t->date = 30;
- time_t->Month = 12;
- time_t->years = 2018;
- while(1){
- for(time_t->secunds =0; time_t->secunds <= MINUTE; time_t->secunds++){
- sleep( 1 );
- printf("\n\tHORA ATUAL: %d : %d : %ds \n",time_t->Hh,time_t->Mm,time_t->secunds);
- printf("\n\t\t[ DATA: %d / %d / %d ] \n",time_t->date,time_t->Month,time_t->years);
- if (time_t->secunds >= 60){
- time_t->Mm = time_t->Mm+1;
- if (time_t->Mm >= 59)
- time_t->Mm =0;
- time_t->Hh = time_t->Hh+1;
- if (time_t->Hh >= 23)
- time_t->date = time_t->date+1;
- time_t->Hh =0;
- if (time_t->date >=30)
- time_t->Month = time_t->Month+1;
- time_t->date =01;
- if(time_t->Month >= 12)
- time_t->years = time_t->years+1;
- time_t->Month =01;
- }else {
- continue;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement