Get program to stop reading line if input is an integer?

Ok I am trying to write a simple program that counts the number of uppercase characters in a line of input. That part i have down, but I also want the program to stop counting if the input is an integer. I am hoping to get this done with a basic a code as possible.


// Program CountUC counts the number of uppercase letters
// on a line.
#include <iostream>
using namespace std;
int main ()
{
char letter;
int letterCt;

cout << "Enter a line of data containing any character type." << endl;
cin.get(letter);

letterCt = 0;

while ( letter != '\n' )
{
if ( letter >= 'A' && letter <= 'Z' )
letterCt++;
cin.get(letter);
}

cout << letterCt << endl;

return 0;
}

Last edited on
Topic archived. No new replies allowed.