| 12
 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
 91
 
 |  
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
 
using namespace std;
 
static void purger(void) {
    int c;
 
    while ((c = getchar()) != '\n' && c != EOF){}
}
 
int ChooseACat () {
    int n = 3;
	// Si char = * exit
    while (n > 2){
       printf ("%s","\nchoisisez parmie les categories suivantes:\n0 sports\n1 musique\n2 pays\n");
       scanf ("%d",&n);
       purger();
    }
    return n;
}
 
int ChooseRandomNumber (int row) {
    int index = 0;
 
    /* initialize random seed: */
	srand ( time(NULL) );
 
	/* generate secret number: */
	index = rand() % row;
 
	return index;
}
 
char ChooseALetter() {
    char letter;
	printf ("%s","\nQuel lettre voulez vous tester:\n");
    scanf ("%c",&letter);
    purger();
	return letter;
}
 
int main (void) {
	// Intialisation des tableaux
	const int row = 10; 
	const int col = 25;
	char sports  [ row ][ col ] = {"soccer","tennis","course","musculation","patin","escalade","natation","ski","gym","escrime"};
	char musique [ row ][ col ] = {"classique","saoul","reggae","jazz","rock","gospel","house","techno","punk","hardcore"};
    char pays    [ row ][ col ] = {"France","Canada","Argentine","Chili","Allemagne","Australie","Japon","Chine","Maroc","Iran"};
 
	// Choix de la categorie 
	int categorie = ChooseACat();
	printf("La categorie choisie est la suivante %d\n",categorie);
 
	// Choix de l'indice du nom a deviner
	int index = ChooseRandomNumber(row);
	printf("random number : %d\n",index);
 
	char *mot;// = sports[index];
	// Creation du tableau contenant le nom a deviner
	if (index == 0) {
	    mot = sports[index];
	}
	else if (index == 1) {
	    mot = musique[index];
	}
	else if (index == 2) {
	    mot = pays[index];
	}
 
 
	int len = sizeof(*mot);
	printf("%d\n",len);
 
	// Creation du tableau contenant le mot decouvert.
	char decouvert[col];
 
	int j = 0;
    while (mot[j] != NULL ) {
		decouvert[j] = '-';
		char letter = decouvert[j];
		j++;
	}
	char letterToTest = ChooseALetter();
	printf("la lettre a teste est %c\n",letterToTest);
 
    return 0;
} |