efrei/programmation-c-cpp/tp3/conversion-majuscule.c

37 lines
595 B
C
Raw Normal View History

2021-11-02 15:41:53 +01:00
/* Conversion en majuscules */
#include <stdio.h>
#include <stdlib.h>
void majuscule(char*);
int main() {
char phrase[100];
int i = 0;
printf("Entrez une phrase en minuscules : ");
fgets(phrase, 100, stdin);
while (phrase[i] != '\n') {
i++;
}
phrase[i] = '\0';
printf("%s\n", phrase);
majuscule(phrase);
printf("%s\n", phrase);
return 0;
}
void majuscule(char* phrase) {
int i = 0;
while (phrase[i] != '\0') {
if ((phrase[i] >= 'a') && (phrase[i] <= 'z')) {
phrase[i] -= 32;
}
i++;
}
}