- #include <time.h>
- #include <iostream>
- using namespace std;
-
- void main()
- {
- //Déclaration variable
- time_t timer1;
- time(&timer1);
- int sec1, min1, hour1, sec2, min2, hour2;
- struct tm *newTime1;
-
- //Récupération heure systeme
- newTime1=localtime(&timer1);
-
- //Mise à jour variable
- hour1=newTime1->tm_hour;
- min1=newTime1->tm_min;
- sec1=newTime1->tm_sec;
-
- //Premier affichage
- cout<<"heure : "<<hour1<<endl;
- cout<<"minute : "<<min1<<endl;
- cout<<"seconde : "<<sec1<<endl;
- cout<<"******************"<<endl;
- cout<<endl;
-
- //Temporisation de 5 secondes
- sec2=0;
- sec1 = sec1 +5;
- while(sec2 != sec1)
- {
- time_t timer2;
- time(&timer2);
- struct tm *newTime2;
- newTime2=localtime(&timer2);
-
- //Mise à jour variable
- hour2=newTime2->tm_hour;
- min2=newTime2->tm_min;
- sec2=newTime2->tm_sec;
- }
-
- //Deuxieme affichage
- cout<<"heure : "<<hour2<<endl;
- cout<<"minute : "<<min2<<endl;
- cout<<"seconde : "<<sec2<<endl;
- cout<<endl;
- }
-
#include <time.h>
#include <iostream>
using namespace std;
void main()
{
//Déclaration variable
time_t timer1;
time(&timer1);
int sec1, min1, hour1, sec2, min2, hour2;
struct tm *newTime1;
//Récupération heure systeme
newTime1=localtime(&timer1);
//Mise à jour variable
hour1=newTime1->tm_hour;
min1=newTime1->tm_min;
sec1=newTime1->tm_sec;
//Premier affichage
cout<<"heure : "<<hour1<<endl;
cout<<"minute : "<<min1<<endl;
cout<<"seconde : "<<sec1<<endl;
cout<<"******************"<<endl;
cout<<endl;
//Temporisation de 5 secondes
sec2=0;
sec1 = sec1 +5;
while(sec2 != sec1)
{
time_t timer2;
time(&timer2);
struct tm *newTime2;
newTime2=localtime(&timer2);
//Mise à jour variable
hour2=newTime2->tm_hour;
min2=newTime2->tm_min;
sec2=newTime2->tm_sec;
}
//Deuxieme affichage
cout<<"heure : "<<hour2<<endl;
cout<<"minute : "<<min2<<endl;
cout<<"seconde : "<<sec2<<endl;
cout<<endl;
}