Translated all function and vars in english, removed useless vars, added some comments

This commit is contained in:
Matthis FAUVET 2024-10-15 11:48:19 +02:00
parent 9bc84202a2
commit 99bf671e61

37
pendu.c
View File

@ -36,43 +36,46 @@ void display_hangman(int tries) {
} }
/* Choix_diff
this function allow user to play with multiple at the same time after user said amount of playable chars
*/
char* choix_diff(){ char* choix_diff(){
int compteur_mot = 0; int word_account = 0; //word_count
int taille = 0; int size = 0; //size
int i = 0; int i = 0;
printf("Choisissez la difficulté du jeu en choisissant la taille : ");
scanf(" %d", &taille); printf("chosed_wordsez la difficulté du jeu en chosed_wordsant la size : ");
scanf(" %d", &size); //&size
static char word_finale[100] = ""; static char word_finale[100] = "";
const char *choisis[MAX_WORDS]; const char *chosed_word[MAX_WORDS]; //chosed_word
word_finale[0] = '\0'; word_finale[0] = '\0';
while (taille >= 3) { while (size >= 3) {
const char *word; const char *word;
int word_length; int word_length;
do { do {
word = words[rand() % MAX_WORDS]; word = words[rand() % MAX_WORDS];
word_length = strlen(word); word_length = strlen(word);
for(i;i<compteur_mot;i++){ for(i;i<word_account;i++){
if(word == choisis[i]){ if(word == chosed_word[i]){ //chosed_word
word_length = taille + 1; word_length = size + 1; //size
} }
} }
} while (word_length > taille); } while (word_length > size);
choisis[compteur_mot] = word; chosed_word[word_account] = word;
compteur_mot++; word_account++;
strcat(word_finale, word); strcat(word_finale, word);
taille -= word_length; size -= word_length;
if(taille > 3){ if(size > 3){
strcat(word_finale, "-"); strcat(word_finale, "-");
} }
} }
@ -81,8 +84,6 @@ char* choix_diff(){
} }
int main() { int main() {
srand(time(NULL));
char *word = choix_diff(); char *word = choix_diff();
int word_length = strlen(word); int word_length = strlen(word);
char guessed[word_length]; char guessed[word_length];