/****************************************************** Arturo Ramos Jr 800-34-1344 Lab - 10 Descriptopn - This program will count each letter of a word but will also count whitespaces, - ... etc *******************************************************/ #include #include bool alphabetic (const char c) { if ( (c >= 'a' && c <='z' ) || (c >='A' && c <='Z') || c == '-') return true; else return false; } void readLine (char buffer[]) { char character; int i = 0; do { character = getchar(); buffer[i] = character; ++i; } while(character != '\n'); buffer [i-1] = '\0'; } int countLetters (const char string[]) { int i, letterCount = 0; bool lookingForLetter = true, alphabetic (const char c); for (i = 0; string[i] != '0'; ++i) if (lookingForLetter) { ++letterCount; lookingForLetter = true; } else if(string[i] == ' ') { letterCount = 0; ++letterCount; lookingForLetter = true; } else lookingForLetter = true; return letterCount; } int main (void) { char text[81]; int totalLetters = 0; int countLetters (const char string[]); void readLine (char buffer[]); bool endOfText = false; while(!endOfText) { readLine(text); if(text[0] == ' ') printf("\n"); else if(text[0] == '0') endOfText = true; else totalLetters += countLetters(text); } printf ("Word = %s Number = %i", text, totalLetters); return 0;