// This program takes in a string, and counts // the number of alphabetic chars, numeric chars, and special // chars in that string // Week 4 Lecture 8 #include #include // New library that can help us test/map characters // #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 alpha_count = 0; int num_count = 0; int special_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 makes each type of char? // There are even some special functions you can use for this! printf("There are %d alphas, %d nums and %d special chars\n", alpha_count, num_count, special_count); return 0; }