Compare commits

..

5 commits
3 ... main

Author SHA1 Message Date
6e1d65a638 fixed a bug that added extra characters in the word obfuscated 2021-10-04 10:17:33 +02:00
2267eda745 Update README.md 2021-09-21 17:29:38 +00:00
1a3d0320f6 Update .gitlab-ci.yml file 2021-09-21 17:26:19 +00:00
a9a45e0512 Update folder name 2021-09-21 17:18:33 +00:00
7f111867c4 Update README.md 2021-07-27 22:46:32 +00:00
3 changed files with 27 additions and 10 deletions

12
.gitlab-ci.yml Normal file
View file

@ -0,0 +1,12 @@
image: gcc
stages:
- build
build:
stage: build
script:
- gcc main.c -o pendu
artifacts:
paths:
- pendu

View file

@ -1,4 +1,6 @@
# Pendu
Mon premier pendu tout language confondu, s'il y a des approximations tu peux faire une PR 😀
Pour lancer le pendu : `git clone https://github.com/Mylloon/pendu-C.git && cd pendu-C && gcc main.c -o main && ./main listeMots.txt` devrait fonctionner.
Pour lancer le pendu : `git clone https://gitlab.com/Mylloon/penduEnC.git && cd penduEnC && gcc main.c -o main && ./main listeMots.txt` devrait fonctionner.
Tu peux aussi télécharger l'artéfact de la [dernière pipeline](https://gitlab.com/Mylloon/penduEnC/-/pipelines/).

21
main.c
View file

@ -48,28 +48,31 @@ 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;
int caractereSpecial(char lettre) { // vérification que la lettre n'est pas un caractere special
if(lettre == ' ') return 1;
if(lettre == '\'') return 1;
if(lettre == '-') 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 tailleMotCache = taille * sizeof(char) * 2;
char * motCache = malloc(tailleMotCache); // x2 pour l'espace entre les "_"
int j = 0;
for(int i = 0; i < taille; i++) {
if(lettresValidees[i] != 1) {
if(caractereSpecial(mot[i]) == 0) motCache[j] = '_'; else {
if(lettresValidees[i] != 1) { // pas trouvé
if(caractereSpecial(mot[i]) == 0) motCache[j] = '_'; // si c'est pas un caractère spéciale
else { // si c'en est un
motCache[j] = mot[i];
lettresValidees[i] = 1;
}
} else motCache[j] = mot[i];
} else motCache[j] = mot[i]; // trouvé
motCache[j + 1] = ' '; // on rajoute un espace entre les underscores
j = j + 2;
}
for(int i = 0; i < longueurMot(motCache); i++)
if(i >= tailleMotCache) motCache[i] = 0;
return motCache;
}