converting to lowercase and eliminating doubled-up case labels

This commit is contained in:
Dan Buch 2011-09-13 23:01:10 -04:00
parent 0b7dbc78b4
commit d85c6d97eb

27
ex13.c
View File

@ -8,37 +8,40 @@ int main(int argc, char *argv[])
}
int i = 0;
for(i = 0; argv[1][i] != '\0'; i++) {
char letter;
int up_low_sep = (int)('a' - 'A');
int upper_floor = (int)'A';
int upper_ceil = (int)'Z';
for(i = 0; '\0' != (letter = argv[1][i]); i++) {
char letter = argv[1][i];
int i_letter = (int)letter;
if (upper_floor < i_letter && i_letter < upper_ceil) {
letter = (char)(i_letter + up_low_sep);
}
switch(letter) {
case 'a':
case 'A':
printf("%d: 'A'\n", i);
printf("%d: 'a'\n", i);
break;
case 'e':
case 'E':
printf("%d: 'E'\n", i);
printf("%d: 'e'\n", i);
break;
case 'i':
case 'I':
printf("%d: 'I'\n", i);
printf("%d: 'i'\n", i);
break;
case 'o':
case 'O':
printf("%d: 'O'\n", i);
printf("%d: 'o'\n", i);
break;
case 'u':
case 'U':
printf("%d: 'U'\n", i);
printf("%d: 'u'\n", i);
break;
case 'y':
case 'Y':
if (i > 2) {
printf("%d: 'Y'\n", i);
} else {