xralier
10/17/2016 - 9:59 AM

checks many things in a string

checks many things in a string

// MADE BY Xralier
#include <bits/stdc++.h>
using namespace std;
int main ()
{
  int i;
  int alnum=0,digit=0,space=0,alpha=0,lower=0,upper=0,punct=0,graph=0; 
  string str;
  getline(cin,str,'\n');
  
  for (i=0; i < str.length() ; ++i ) 
     	   {
               if ( isalnum(str[i]) )
               alnum++; 
               if ( isalpha(str[i]) )
               alpha++; 
               if ( isdigit(str[i]) )
               digit++; 
               if ( islower(str[i]) )
               lower++; 
               if ( isupper(str[i]) )
               upper++; 
               if ( ispunct(str[i]) )
               punct++; 
               if ( isgraph(str[i]) )
               graph++; 
               if ( isspace(str[i]) )
               space++; 


  	       }

cout<<"length :"<<i<<endl;
cout<<"Alphanumeric : "<<alnum<<endl;
cout<<"Alpha : "<<alpha<<endl;
cout<<"Digit : "<<digit<<endl;
cout<<"Lowercase : "<<lower<<endl;
cout<<"Uppercase : "<<upper<<endl;
cout<<"Punctuation : "<<punct<<endl;
cout<<"Characters Without Space : "<<graph<<endl;
cout<<"Space : "<<space<<endl;
  return 0;
}