//John T. Rine //September 10, 2011 (Revised) //This function is the basis for a set of string handling routines //$ ./cntChars Hello Jenny Sue! //There are 5 characters in string 1 //There are 5 characters in string 2 //There are 4 characters in string 3 //$ ./cntChars "John Rine" "Likes to" Program! //There are 9 characters in string 1 //There are 8 characters in string 2 //There are 8 characters in string 3 #include int cntChars(char *); int main(int argc, char **argv) { int i; if (argc > 1) for(i = 1; i <= (argc - 1); i++) printf("There are %d characters in string %d\n", cntChars(*(argv + i)), i); else printf("No command line arguments were supplied after the file name\n"); return(0); } int cntChars(char *inputString) { // returned value "count" does not include // '\0' int count = 0; while(*(inputString + count) != '\0') ++count; return(count); }