box-o-sand/lcthw-remnants/ex14.c

36 lines
586 B
C
Raw Normal View History

2011-09-18 14:35:00 +00:00
#include <stdio.h>
#include <ctype.h>
#include <string.h>
2011-09-18 14:35:00 +00:00
void print_letters(char arg[], int nchars);
2011-09-18 14:35:00 +00:00
void print_arguments(int argc, char *argv[])
{
int i = 0;
for(i = 0; i < argc; i++) {
print_letters(argv[i], strlen(argv[i]));
2011-09-18 14:35:00 +00:00
}
}
void print_letters(char arg[], int nchars)
2011-09-18 14:35:00 +00:00
{
int i = 0;
for (i = 0; i < nchars; i++) {
2011-09-18 14:35:00 +00:00
char ch = arg[i];
2011-09-18 14:41:52 +00:00
if(isalpha(ch) || isblank(ch)) {
2011-09-18 14:35:00 +00:00
printf("'%c' == %d ", ch, ch);
}
}
printf("\n");
}
int main(int argc, char *argv[])
{
print_arguments(argc, argv);
return 0;
}