Fix mirroir

This commit is contained in:
flyingscorpio@arch-desktop 2021-11-02 22:37:37 +01:00
parent df4ab3148e
commit 4a6e621856

View file

@ -14,9 +14,7 @@ int main() {
printf("Entrez une phrase : "); printf("Entrez une phrase : ");
fgets(phrase, 100, stdin); fgets(phrase, 100, stdin);
while (phrase[i] != '\n') { while (phrase[i] != '\n') i++;
i++;
}
phrase[i] = '\0'; phrase[i] = '\0';
mirroir(phrase, phrase_mirroir); mirroir(phrase, phrase_mirroir);
@ -27,15 +25,8 @@ int main() {
void mirroir(char *phrase, char *phrase_mirroir) { void mirroir(char *phrase, char *phrase_mirroir) {
int len_phrase = strlen(phrase); int len_phrase = strlen(phrase);
int j = len_phrase;
for (int i = 0; i < len_phrase + 1; i++) { for (int i = 0; phrase[i] != '\0'; i++) {
phrase_mirroir[i] = phrase[j]; phrase_mirroir[i] = phrase[len_phrase - 1 - i];
printf("%c", phrase_mirroir[i]);
j--;
} }
phrase_mirroir[len_phrase] = '\0';
// TODO: finir
printf("%s | %s\n", phrase, phrase_mirroir);
} }