You should pass int to isalpha() , not char . Pay attention to the standard prototype for this function:
int isalpha(int c);
Passing an 8-bit signed character will convert the value to a negative integer, which will result in an unlawful negative offset into the internal arrays commonly used by isxxxx() .
However, you must make sure that your char treated as unsigned when casting - you cannot just pass it directly to int , because if it is an 8-bit character, the resulting int will be negative.
A typical way to ensure this is to pass it to an unsigned char , and then rely on an implicit type conversion to convert it to int .
eg.
char c = '£'; int a = isalpha((unsigned char) c);
Alnitak
source share