handling all args passed

This commit is contained in:
Dan Buch 2011-09-13 23:05:09 -04:00
parent d85c6d97eb
commit 4c87139ab0

13
ex13.c
View File

@ -2,19 +2,21 @@
int main(int argc, char *argv[])
{
if(argc != 2) {
printf("ERROR: You need one argument.\n");
if (argc < 2) {
fprintf(stderr, "ERROR: You must provide at least one argument.\n");
return 1;
}
int i = 0;
int i;
int argn;
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];
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);
@ -53,6 +55,7 @@ int main(int argc, char *argv[])
printf("%d: '%c' is not a vowel\n", i, letter);
}
}
}
return 0;
}