using strlen instead of null terminator
This commit is contained in:
parent
20da5c59fd
commit
c9de7b1c13
9
ex14.c
9
ex14.c
@ -1,22 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user