#include <iostream>
using namespace std ;
#define MAX_STR_LENGTH 50
int main() {
char str[MAX_STR_LENGTH];
// set pointer to beginning of str
char* ptr = &str[0];
// get string from user
std::cout << "Enter string (N < " << MAX_STR_LENGTH << ") :";
std::cin.getline (str, MAX_STR_LENGTH);
std::cout << std::endl;
// loop while the pointer does not point to a null byte
// move the pointer one position at the end of the loop
unsigned int chars_capital = 0, chars_lower = 0, chars_digits = 0, chars_other = 0;
while ( *ptr != 0 )
{
if ( *ptr >= 'A' && *ptr <= 'Z' )
++chars_capital;
}
else if ( *ptr >= 'a' && *ptr <= 'z' )
++chars_lower;
else if ( *ptr >= '0' && *ptr <= '9' )
++chars_digits;
else
++chars_other;
// move pointer one char further
++ptr;
std::cout << chars_capital << " Uppercase" << std::endl;
std::cout << chars_lower << " Lowercase" << std::endl;
std::cout << chars_digits << " Digits" << std::endl;
std::cout << chars_other << " Other" << std::endl;
return 0 ;