box-o-sand/oldstuff/lcthw-remnants/ex13.c

63 lines
1.5 KiB
C
Raw Normal View History

2011-09-14 01:43:47 +00:00
#include <stdio.h>
int main(int argc, char *argv[])
{
2011-09-14 03:05:09 +00:00
if (argc < 2) {
fprintf(stderr, "ERROR: You must provide at least one argument.\n");
2011-09-14 01:43:47 +00:00
return 1;
}
2011-09-14 03:05:09 +00:00
int i;
int argn;
char letter;
int up_low_sep = (int)('a' - 'A');
int upper_floor = (int)'A';
int upper_ceil = (int)'Z';
2011-09-14 03:05:09 +00:00
for(argn = 1; argn < argc; argn++) {
for(i = 0; '\0' != (letter = argv[argn][i]); i++) {
int i_letter = (int)letter;
if (upper_floor < i_letter && i_letter < upper_ceil) {
letter = (char)(i_letter + up_low_sep);
}
2011-09-14 03:07:39 +00:00
switch(letter) {
case 'a':
printf("%d: 'a'\n", i);
break;
case 'e':
printf("%d: 'e'\n", i);
break;
case 'i':
printf("%d: 'i'\n", i);
break;
case 'o':
printf("%d: 'o'\n", i);
break;
case 'u':
printf("%d: 'u'\n", i);
break;
case 'y':
if (i > 2) {
printf("%d: 'Y'\n", i);
} else {
printf("%d: 'Y' isn't a vowel this time\n", i);
}
break;
default:
printf("%d: '%c' is not a vowel\n", i, letter);
2011-09-14 03:05:09 +00:00
}
2011-09-14 01:43:47 +00:00
}
}
return 0;
}