From 7ecb0e8c396b5b438078e5d33bc1d1149ccfc887 Mon Sep 17 00:00:00 2001 From: leriche <lerichetitouan@gmail.com> Date: Tue, 12 Dec 2023 13:52:49 +0100 Subject: [PATCH 1/2] test fenettre compteur score --- snake/ajout_score.c | 80 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/snake/ajout_score.c b/snake/ajout_score.c index 6af29e4..acd7211 100644 --- a/snake/ajout_score.c +++ b/snake/ajout_score.c @@ -3,13 +3,91 @@ #include <stdlib.h> #include <graph.h> +#include <stdio.h> -void ajout_scorescore (unsigned int compteur) { +/*int main(unsigned int compteur) { compteur = compteur + 5; char* a= (int) compteur; EcrireTexte(1250, 600, a, 2); +}*/ + + + + +/* +int main() { + int compteur = 10; + + compteur = compteur + 5; + + + char a[20]; + sprintf(a, "%d", compteur); + + + EcrireTexte(1250, 600, a, 2); + + return 0; +} +*/ + + + +void ajout_score(int* compteur) { + + + char a[20]; + + + &compteur = &compteur + 5; + + sprintf(a, "%d", &compteur); + + InitialiserGraphique(); + CreerFenetre(10,10,1450,840); + + EcrireTexte(1250, 600, a, 2); + + Touche(); + FermerGraphique(); +} + +int main(void) { + + int *compteur = NULL; + compteur = malloc(sizeof(int)); + &compteur = 0; + ajout_score(compteur); + + return EXIT_SUCCESS; + +} + +/* +int main() { + int compteur = 0; + char key; + + printf("Appuyez sur ESPACE pour ajouter 5 (Appuyez sur 'q' pour quitter)\n"); + + while (1) { + key = getchar(); + if (key == ' ') { + compteur += 5; + printf("Compteur : %d\n", compteur); + } else if (key == 'q' || key == 'Q') { + printf("Sortie du programme.\n"); + break; + } + } + + return 0; } +*/ + + + From 6d4ab18cf57ce539b27ac97031ff99ea90994c95 Mon Sep 17 00:00:00 2001 From: leriche <lerichetitouan@gmail.com> Date: Tue, 12 Dec 2023 15:48:31 +0100 Subject: [PATCH 2/2] =?UTF-8?q?compteur=20score=20op=C3=A9rationel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- snake/ajout_score.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/snake/ajout_score.c b/snake/ajout_score.c index acd7211..6fd2d16 100644 --- a/snake/ajout_score.c +++ b/snake/ajout_score.c @@ -40,9 +40,9 @@ void ajout_score(int* compteur) { char a[20]; - &compteur = &compteur + 5; + *compteur = *compteur + 5; - sprintf(a, "%d", &compteur); + sprintf(a, "%d", *compteur); InitialiserGraphique(); CreerFenetre(10,10,1450,840); @@ -57,8 +57,9 @@ int main(void) { int *compteur = NULL; compteur = malloc(sizeof(int)); - &compteur = 0; + *compteur = 0; ajout_score(compteur); + free(compteur); return EXIT_SUCCESS;