#include <ctype.h> int isalpha(int c);
isalpha
tests an integer value c
to determine whether it is an
alphabetic (uppercase or lowercase) character. In the C locale,
isalpha
returns true only for the characters for which isupper
or
islower
is true.
isalpha
returns 0 if the character is not alphabetic, or a nonzero
value if it is alphabetic. If the argument is EOF
, 0 is returned.
isalpha
on a noncharacter argument other than EOF
is undefined. Do not assume that isalpha
returns either 0 or 1.
#include <ctype.h> #include <stdio.h> #define MAXLEN 40 main() { char id[MAXLEN+1]; int i; char *text; char input[MAXLEN]; puts("Enter a string (40 characters maximum). "); text = gets(input); puts("Initial alphabetic characters you entered:"); for (i = 0; i < MAXLEN && isalpha(text[i]); i++) { id[i] = text[i]; putc(id[i]); } id[i] = '0'; putc('n'); }
islower
, isupper
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.