From b4f25a50b090721a8319848cb1b9fbe7788c1d27 Mon Sep 17 00:00:00 2001 From: rocherl Date: Tue, 15 Oct 2024 11:32:43 +0200 Subject: [PATCH] ajout du cooldown sur le scanf --- .vscode/settings.json | 5 +++++ pendu | Bin 0 -> 16160 bytes pendu.c | 12 ++++++++++++ 3 files changed, 17 insertions(+) create mode 100644 .vscode/settings.json create mode 100755 pendu diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..1992e5c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "unistd.h": "c" + } +} \ No newline at end of file diff --git a/pendu b/pendu new file mode 100755 index 0000000000000000000000000000000000000000..e9aae9091bba0ad7ecac483fbf0965ec05a42109 GIT binary patch literal 16160 zcmeHOeQ*@z8GrARXhh%w1A?C{C>^5aNMe8>QjU*6Gb3)S|T(m2!Qacb{joS?|>G zpU$-RB)iZ1{GN~ZeV=`A_ubuh9|*5q?f3ZvQ<33FV?-#p^%hv`DU5%L=$KZj$3P*0rm zi8;Zomg0GN2y{pxxfjCg*Ft_?zKZObV;xAF&sxz>Qr|}MJ2c0RL|`=1o*zzT;3yI~LZ=k3}nDW<1?e(NepxVqr}%l?YbLCSbcNVZ&jw zX8l&-Zxua=vA<9F#>sw?!9)_;PJ<28j{e_!Z1L+ee)Feo-M7?kpL6`|g7u3oK87~f z4~&U6NQmLaggV|B`#5|a7){M#_$**b4jk*qWj{L)j>jsO{f0bvEDwHr9(-FKybo{% zHZS3MBv*Ux$%D_xgP#Fhfz3-H0BA^$Q!N20SG}S+ZKZ^!r7S(NQ;Rh2)arFJCX5!- z5|-Iyh?JF#8F8?Hffzxvq@^|KW?ZC_dOQkvq(#^2&A1*j_ZXr%X~wO3kun4dBQV~5~FZ7t6Y!Vm;$L~V1W^LVym0ERhkyEO1O4Y#yPWiSPq1A0!r$vpV(O{-5 zBe`YW%2*<9Y|(eb45+1{DG{fpX|`!jLm^=F!$>cJk&Ao$L%D=F{sw%Y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t)h%7%5_^*tBQ64ZWJe7^x4;i0XTP8m`81;IGq`{9W$ zd~N_ahIH*nrKlG9K|$0^HOKVb7^fyP$p*2RqmnGXn)00UZ8j2oVhQNB08G%|85DRueS%Do44vYv! z5>4`f`S_p5CzWvi20ul5%KyRd?Rfsi@zK^zH-dn3CO?6-Gy!8CBAl6=B(VT|A#85{ z7V>8gCDIb4C!#>R^+jmhkP4iq?c=(OR?$DQwMF*!gu{*l;^kK@~b zp$Yr*_e(wV(OQUkHgopu&-`7`xc&LQHADW*j;CE>A2ZQf-wXRkOV zyMVthjK%HedEI&P=X%%;>vGd1s-Mgq75jUCf9&t(JoX%CD3n#%5?=@KJdDSQ+r#Hi kypQ6x+aC6QKMmZAToEZfBFx=$`#*>mCZMZ44jxhb2X7#O2mk;8 literal 0 HcmV?d00001 diff --git a/pendu.c b/pendu.c index 1b0cfd6..1231cbb 100644 --- a/pendu.c +++ b/pendu.c @@ -1,7 +1,9 @@ +#include #include #include #include #include +#include #define MAX_WORDS 14 #define MAX_TRIES 6 @@ -35,6 +37,11 @@ void display_hangman(int tries) { } } +void sig_handler(int signum){ + printf("\ntime out\n"); + exit (1); +} + int main() { srand(time(NULL)); const char *word = words[rand() % MAX_WORDS]; @@ -43,16 +50,21 @@ int main() { int tries = 0; int guessed_correctly = 0; + signal(SIGALRM,sig_handler); + for (int i = 0; i < word_length; i++) { guessed[i] = '_'; } guessed[word_length] = '\0'; while (tries < MAX_TRIES && guessed_correctly < word_length) { + printf("\nMot à deviner : %s\n", guessed); display_hangman(tries); char guess; + alarm(30); printf("Entrez une lettre : "); + alarm(30); scanf(" %c", &guess); int found = 0; -- 2.47.0