fix
This commit is contained in:
parent
6338aa6815
commit
6a39663c84
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -1,6 +1,7 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"algorithm": "c",
|
||||
"format": "c"
|
||||
"format": "c",
|
||||
"cstdlib": "c"
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
ex2 les functionnalité ont etait codé la mienne ne functionne pas pour l instant on passe
|
||||
|
||||
la creation de pull request
|
13
pendu.c
13
pendu.c
@ -24,6 +24,11 @@ const char *words[MAX_WORDS] = {
|
||||
"eclesiastique"
|
||||
};
|
||||
|
||||
// Prototypes des fonctions
|
||||
char** selecte_words(int word_length, int* size);
|
||||
char** word_merge(int word_length, int* size2);
|
||||
char** merge_string_arrays(char** array1, char** array2, int size1, int size2);
|
||||
|
||||
void display_hangman(int tries) {
|
||||
switch (tries) {
|
||||
case 0: printf(" ----\n | |\n |\n |\n |\n |\n--------\n"); break;
|
||||
@ -80,6 +85,12 @@ char* difficult(int word_length) {
|
||||
// Sélectionner un mot aléatoire
|
||||
char* chosen_word = final_words[rand() % (size1 + size2)];
|
||||
|
||||
// Libérer la mémoire du tableau final_words après avoir choisi un mot
|
||||
for (int i = 0; i < size1 + size2; i++) {
|
||||
free(final_words[i]);
|
||||
}
|
||||
free(final_words);
|
||||
|
||||
return chosen_word;
|
||||
}
|
||||
|
||||
@ -168,7 +179,7 @@ int main() {
|
||||
|
||||
int word_length = ask_word_length();
|
||||
const char* word = difficult(word_length);
|
||||
|
||||
printf("le mot est :%s",word);
|
||||
if (word == NULL) {
|
||||
printf("Erreur : aucun mot disponible avec cette longueur.\n");
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user