I have the character count program that works like it should, but I can't figure out code to count the number of non-alphanumeric characters. Non alphanumeric characters are !@#$%^&*() basically they are any characters that do not contain the value of a number or a letter. Is there code to find non-alphanumeric characters?
Code:
#include<stdio.h>
#include<conio.h>
void main()
{
int length=0,upper=0,lower=0,digits=0;
char str[80];
char strlen[80];
int i;
printf("\nEnter The String : ");
gets(str);
i=0;
while(strlen[length]!='\0')
length++;
while(str[i]!='\0')
{
if(str[i]>='A' && str[i]<='Z')
upper++;
if(str[i]>='a' && str[i]<='z')
lower++;
if(str[i]>='0' && str[i]<='9')
digits++;
i++;
}
printf("\nLength of the String is : %d",length);
printf("\nUppercase Letters : %d",upper);
printf("\nLowercase Letters : %d",lower);
printf("\nDigits : %d",digits);
getch();
}