From c9de7b1c13eed4c4750d12bd28c82e5b0a24d2ca Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sun, 18 Sep 2011 10:40:21 -0400 Subject: [PATCH] using strlen instead of null terminator --- ex14.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ex14.c b/ex14.c index 6eeacbe..403769b 100644 --- a/ex14.c +++ b/ex14.c @@ -1,22 +1,23 @@ #include #include +#include -void print_letters(char arg[]); +void print_letters(char arg[], int nchars); void print_arguments(int argc, char *argv[]) { int i = 0; for(i = 0; i < argc; i++) { - print_letters(argv[i]); + print_letters(argv[i], strlen(argv[i])); } } -void print_letters(char arg[]) +void print_letters(char arg[], int nchars) { int i = 0; - for (i = 0; arg[i] != '\0'; i++) { + for (i = 0; i < nchars; i++) { char ch = arg[i]; if(isalpha(ch) || isblank(ch)) {