So I have this program that tells you the number of characters and vowels in a paragraph.
Here is the code
#include <iostream>
using namespace std;
int main()
{
cout<<"Enter your paragraph\nTo finish press 'ESC'\n\n";
//27 Is The ESC Button In ASCII
char s[500];
cin.getline(s, 500, 27);
//Vowel and Character counters
long long vowels = 0, characters = 0;
for(int i = 0; i<500; i++) s[i] = tolower(s[i]);
for(int i = 0; i<500; i++) {
if(s[i] == 'a'||s[i] == 'e'||s[i] == 'i'||s[i] == 'o'||s[i] == 'u'||s[i] == 'y')vowels++;
if(s[i] >= 32 && s[i] <= 126) characters++;
}
cout<<"The amount of characters: "<<characters<<"\nThe amount of vowels: "<<vowels<<'\n';
}
How do I make it so that when the user presses ESC, it immediately does the output (On Mac)?
When the user presses ESC, it's supposed to print the number of characters and vowels in your paragraph, but when you press ESC, you must press enter actually to output.