lcthw ex14 extra credit

This commit is contained in:
Dan Buch 2024-04-19 21:22:10 -04:00
parent d2d54c12a8
commit b979a794d6
Signed by: meatballhat
GPG Key ID: A12F782281063434

View File

@ -1,27 +1,27 @@
#include <stdio.h>
#include <ctype.h>
#include <string.h>
// forward declarations
int can_print_it(char ch);
void print_letters(char arg[]);
void print_letters(size_t len, char arg[]);
void print_arguments(int argc, char *argv[])
{
int i = 0;
for (i = 0; i < argc; i++) {
print_letters(argv[i]);
print_letters(strlen(argv[i]), argv[i]);
}
}
void print_letters(char arg[])
void print_letters(size_t len, char arg[])
{
int i = 0;
for (i = 0; arg[i] != '\0'; i++) {
for (i = 0; i < len; i++) {
char ch = arg[i];
if (can_print_it(ch)) {
if (isprint((int)ch)) {
printf("'%c' == %d ", ch, ch);
}
}
@ -29,11 +29,6 @@ void print_letters(char arg[])
printf("\n");
}
int can_print_it(char ch)
{
return isalpha((int)ch) || isblank((int)ch);
}
int main(int argc, char *argv[])
{
print_arguments(argc, argv);