// This program takes in a string, and counts // the number of words in that string // Week 4 Lecture 8 #include #include // Define the size of the array = this is clearly going to cause some // waste - one of the downfalls of arrays #define MAX_LENGTH 124 int main(void) { // Declare our array to hold the string char word[MAX_LENGTH]; int count = 0; printf("Type in a sentence: "); // Read in the string using fgets() function fgets(word, MAX_LENGTH, stdin); // Do some magic here to calculate: // What separates out words? what could I be looking for? printf("There are %d words in the string\n", count); return 0; }