This commit is contained in:
Geoffrey Frogeye 2016-03-09 11:09:19 +01:00
parent 86f2df33ed
commit e280898bf4

47
TP3/E8.c Normal file
View file

@ -0,0 +1,47 @@
/* Mise en majuscules / minuscules */
#include <stdio.h>
#define N 255
int length(char* c) {
int i, len = -1;
for (i = 0; i < N; i++) {
if (c[i] == '\0') {
len = i;
break;
}
}
return len;
}
void majuscule(char* c) {
int i, len = length(c);
for (i = 0; i < len; i++) {
if ('a' <= c[i] && c[i] <= 'z') {
c[i] += 'A' - 'a';
}
}
}
void minuscule(char* c) {
int i, len = length(c);
for (i = 0; i < len; i++) {
if ('A' <= c[i] && c[i] <= 'Z') {
c[i] += 'a' - 'A';
}
}
}
int main() {
char c[N];
printf("Entrez du texte : ");
scanf("%s", &c);
majuscule(c);
printf("Majuscules : %s (addresse : 0x%x)\n", c, &c);
minuscule(c);
printf("Minuscules : %s (addresse : 0x%x)\n", c, &c);
return 0;
}