How to use isalpha() function to check whether a character is an alphabetic letter in C

1 Answer

0 votes
#include <stdio.h>
#include <ctype.h>
 
int main(void)
{
    char s[] = "Unreal Engine 4 - DirectX 12";
	int i = 0;
	
	while (s[i])
	{
		if (isalpha(s[i])) 
			printf ("%c is alphabetic\n", s[i]);
		else 
			printf ("%c is not alphabetic\n", s[i]);
		i++;
	}
    return 0;
}
 
  
/*
    
run:
    
U is alphabetic
n is alphabetic
r is alphabetic
e is alphabetic
a is alphabetic
l is alphabetic
  is not alphabetic
E is alphabetic
n is alphabetic
g is alphabetic
i is alphabetic
n is alphabetic
e is alphabetic
  is not alphabetic
4 is not alphabetic
  is not alphabetic
- is not alphabetic
  is not alphabetic
D is alphabetic
i is alphabetic
r is alphabetic
e is alphabetic
c is alphabetic
t is alphabetic
X is alphabetic
  is not alphabetic
1 is not alphabetic
2 is not alphabetic

*/

 



answered Jan 28, 2016 by avibootz
...