Checks whether c is an alphabetic letter. Notice that what is considered a letter depends on the locale being used.
int isalpha ( int c );
This function has the following parameter.
A value different from zero (i.e., true) if indeed c is an alphabetic letter. Zero (i.e., false) otherwise.
#include <stdio.h>
#include <ctype.h>
int main (){//from w w w .j av a 2s . c om
int i=0;
char str[]="C++";
while (str[i]) {
if (isalpha(str[i]))
printf ("character %c is alphabetic\n",str[i]);
else
printf ("character %c is not alphabetic\n",str[i]);
i++;
}
return 0;
}
The code above generates the following result.
#include <ctype.h>
#include <stdio.h>
#include <locale.h>
// w w w .j av a 2s. c om
int main(void){
unsigned char c = '\xdf'; // German letter ? in ISO-8859-1
printf("isalpha('\\xdf') in default C locale returned %d\n", !!isalpha(c));
setlocale(LC_CTYPE, "de_DE.iso88591");
printf("isalpha('\\xdf') in ISO-8859-1 locale returned %d\n", !!isalpha(c));
}
The code above generates the following result.