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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
   |  
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main(int argc, char *argv[])
{
	/****************
        DECLARATION DES VARIABLES
        ****************/
	char caractereARechercher = 0;
	/* DEBUG
	char motATrouver[5];
	char isLettreTrouver = 0;
	int nombreDeVies = 0;
	int etatPartie = 0;
	int isMotTrouve = 0;	
 
	//Debut du jeu
	printf("Bonjour et bienvenu dans Pendu\n");
	printf("Quel mot faut-il trouver ? ");
	//scanf("%s", motATrouver); 
 
	motATrouver[0] = 't';
	motATrouver[1] = 'e';
	motATrouver[2] = 's';
	motATrouver[3] = 't';
	motATrouver[4] = '\0';
 
	//motATrouver = 'test';
	printf("%s\n", motATrouver);
 
	printf("Combiens de vies pour cette partie ? ");
	//scanf("%ld", &nombreDeVies);
	nombreDeVies = 10;
	printf("%ld\n", nombreDeVies);
	//scanf("%c", &caractereARechercher);
	//Debut de la partie
 
	while (etatPartie == 0)
	******** FIN DEBUG */
	while(1)
	{
		//Proposer la recherche
		printf("Lettre à rechercher: \n");
		scanf("%c", &caractereARechercher);
		printf("Lettre saisie: %c\n", caractereARechercher);
 
		//printf("%c\n",caractereARechercher);
		//Recherche la lettre
		//char* strchr(const char* chaine, int caractereARechercher);
		/*
		isLettreTrouver = strchr(motATrouver, caractereARechercher);
		if (isLettreTrouver != NULL)
		{
			printf("Oui! La lettre est présente !\n");
			//nombreDeVies--;
		}else{
			nombreDeVies--;
			printf("Dommage, la lettre n'est pas présente. Il vous reste %ld vie(s)\n",nombreDeVies);
		}
 
		//Mise à jour de l'état de la partie
		if (nombreDeVies == 0) {etatPartie = 1;}
		if (isMotTrouve == 1) {etatPartie = 2;}
		*/
	}
 
	/*DEBUG
	//Fin de la partie
	switch (etatPartie)
	{
		case 1:
			printf("Perdu! La solution était: %s\n", motATrouver);
		break;
		case 2:
			printf("Gagné! La solution était: %s\n", motATrouver);
		break;
	}
 
	//Fin du jeu
	printf("A bientôt !\n");
	******* FIN DEBUG */
 
  return EXIT_SUCCESS;
} | 
Partager