Final answer:
The goal is to write a program that counts vowel occurrences in a string using an integer array to hold counts and a character array to store input. It involves looping, checking each character for vowels, incrementing counts, and displaying results.
Step-by-step explanation:
The task is to write a program that counts the number of vowel occurrences in a user-provided string. Vowels are considered irrespective of their case ('a' and 'A' are treated the same), and the count should be stored in an integer array of size 5, where each index corresponds to a vowel ('a', 'e', 'i', 'o', 'u'). The user's input, which can be up to 299 characters long, should be stored in a character array of size 300 to accommodate the NULL character appended by the getline() function. A sentinel loop is to be used for handling multiple inputs until an empty string is entered. The strlen() function from the "cstring" library can be used to determine the string's length.
To achieve the task, the program will:
- Use a loop to repeatedly prompt the user for input.
- Parse the input string character by character to identify vowels.
- Increment the corresponding index in the occurrences array when a vowel is encountered.
- Terminate the loop when an empty string is input.
- Finally, display the total count of each vowel to the user.
Using an array to store these counts allows for efficient access and manipulation of the data, while the use of the getline() function streamlines the process of reading input strings. It should be noted that the character array must be large enough to contain the user's input plus the NULL character.