box-o-sand/lcthw/ex14.c

37 lines
539 B
C
Raw Normal View History

2024-04-20 00:53:48 +00:00
#include <stdio.h>
#include <ctype.h>
2024-04-20 01:22:10 +00:00
#include <string.h>
2024-04-20 00:53:48 +00:00
// forward declarations
2024-04-20 01:22:10 +00:00
void print_letters(size_t len, char arg[]);
2024-04-20 00:53:48 +00:00
void print_arguments(int argc, char *argv[])
{
int i = 0;
for (i = 0; i < argc; i++) {
2024-04-20 01:22:10 +00:00
print_letters(strlen(argv[i]), argv[i]);
2024-04-20 00:53:48 +00:00
}
}
2024-04-20 01:22:10 +00:00
void print_letters(size_t len, char arg[])
2024-04-20 00:53:48 +00:00
{
int i = 0;
2024-04-20 01:22:10 +00:00
for (i = 0; i < len; i++) {
2024-04-20 00:53:48 +00:00
char ch = arg[i];
2024-04-20 01:22:10 +00:00
if (isprint((int)ch)) {
2024-04-20 00:53:48 +00:00
printf("'%c' == %d ", ch, ch);
}
}
printf("\n");
}
int main(int argc, char *argv[])
{
print_arguments(argc, argv);
return 0;
}