1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| /* essai avec time.h */
/* commande compil gcc -std=c99 -Wall compte_a_rebours.c -o compte_a_rebours.exe */
#include <stdio.h>
#include <time.h>
void attente(float temps);
int main(void)
{
int compteur;
for(compteur=10;compteur>0;compteur--){
printf("%d...\n", compteur);
attente(12);
}
puts("BONNE ANNEE !!!\n");
return 0;
}
void attente(float temps)
{
clock_t arrivee = clock()+(temps*CLOCKS_PER_SEC); // On calcule le moment où l'attente devra s'arrêter
while(clock()<arrivee);
} |
Partager