This repository has been archived on 2019-08-09. You can view files and clone it, but cannot push or open issues or pull requests.
s4-c/TP3/E8.c
2016-03-09 11:09:19 +01:00

48 lines
859 B
C

/* 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;
}