diff --git a/main.c b/main.c index 4fb9bf8..071b907 100644 --- a/main.c +++ b/main.c @@ -48,12 +48,25 @@ char * recuperationMot(const char file[]) { // pour récupérer un mot aléaotoi return mot; } +int caractereSpecial(char mot) { // vérification que la lettre n'est pas un caractere special + if(mot == ' ') return 1; + if(mot == '\'') return 1; + if(mot == '-') return 1; + + return 0; +} + char * obfuscation(char mot[], int lettresValidees[], int taille) { // pour afficher les trous dans le mot int tailleMot = taille * 2; char * motCache = malloc(tailleMot * sizeof(char)); int j = 0; for(int i = 0; i < taille; i++) { - if(lettresValidees[i] != 1) motCache[j] = '_'; else motCache[j] = mot[i]; + if(lettresValidees[i] != 1) { + if(caractereSpecial(mot[i]) == 0) motCache[j] = '_'; else { + motCache[j] = mot[i]; + lettresValidees[i] = 1; + } + } else motCache[j] = mot[i]; motCache[j + 1] = ' '; // on rajoute un espace entre les underscores j = j + 2; }