Compare commits
3 Commits
master
...
9125414f5a
Author | SHA1 | Date | |
---|---|---|---|
9125414f5a | |||
99bf671e61 | |||
9bc84202a2 |
51
pendu.c
51
pendu.c
@@ -35,9 +35,56 @@ 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(){
|
||||
int word_account = 0; //word_count
|
||||
int size = 0; //size
|
||||
int i = 0;
|
||||
|
||||
printf("chosed_wordsez la difficulté du jeu en chosed_wordsant la size : ");
|
||||
scanf(" %d", &size); //&size
|
||||
|
||||
static char word_finale[100] = "";
|
||||
const char *chosed_word[MAX_WORDS]; //chosed_word
|
||||
|
||||
word_finale[0] = '\0';
|
||||
|
||||
while (size >= 3) {
|
||||
const char *word;
|
||||
int word_length;
|
||||
|
||||
do {
|
||||
word = words[rand() % MAX_WORDS];
|
||||
word_length = strlen(word);
|
||||
for(i;i<word_account;i++){
|
||||
if(word == chosed_word[i]){ //chosed_word
|
||||
word_length = size + 1; //size
|
||||
}
|
||||
}
|
||||
|
||||
} while (word_length > size);
|
||||
|
||||
chosed_word[word_account] = word;
|
||||
word_account++;
|
||||
|
||||
strcat(word_finale, word);
|
||||
|
||||
|
||||
size -= word_length;
|
||||
if(size > 3){
|
||||
strcat(word_finale, "-");
|
||||
}
|
||||
}
|
||||
|
||||
return word_finale;
|
||||
}
|
||||
|
||||
int main() {
|
||||
srand(time(NULL));
|
||||
const char *word = words[rand() % MAX_WORDS];
|
||||
char *word = choix_diff();
|
||||
int word_length = strlen(word);
|
||||
char guessed[word_length];
|
||||
int tries = 0;
|
||||
|
Reference in New Issue
Block a user