From 20ac8f0c9002458406040d007962144c5e6f7ae7 Mon Sep 17 00:00:00 2001 From: "remi.greub" <remi.greub@hes-so.ch> Date: Tue, 25 Mar 2025 23:18:15 +0100 Subject: [PATCH] =?UTF-8?q?correction=20du=20bug=20des=20petits/grands=20c?= =?UTF-8?q?hiffres.=20(note:=20modifier=20le=20scanf=20avec=20une=20foncti?= =?UTF-8?q?on=20qui=20g=C3=A8re=20les=20erreurs.=20avec=20fgetc=20=3F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- puissance4_GRB/puissance4.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/puissance4_GRB/puissance4.c b/puissance4_GRB/puissance4.c index 8ae2152..b40b605 100644 --- a/puissance4_GRB/puissance4.c +++ b/puissance4_GRB/puissance4.c @@ -95,10 +95,15 @@ int Launch_puissance4(){ //print_grille(); print_gameCells(); printf("au tour de %d de jouer\n", game.curr_player); - printf("balance un chiffre entre 0 et %d\n", game.width); - scanf("%d",&chiffre); + printf("balance un chiffre entre 0 et %d\n", game.width-1); + do{ + scanf("%d",&chiffre); + if(chiffre >= game.width || chiffre < 0){ + printf("HEP HEPHEP !! donne un chiffre dans la plage donnee manche a couille\n"); + } + }while(chiffre >= game.width || chiffre < 0); - game.gamePlayed -= 1; + game.gamePlayed -= 1; //peut ĂȘtre le mettre plus bas non ? int i = 0; //verifier que put free cell fonctionne if((i = put_free_cell(chiffre, 0, game.players[game.curr_player].symbol))<0){ -- GitLab