#include <lctype.h> int iscsymf(int c);
iscsymf
tests an integer value to determine whether it is a
character that can appear as the first character of a C identifier.
For this implementation, the uppercase and lowercase alphabetic
characters and the underscore are included.
iscsymf
returns 0 if the character is not a valid first character
in a C identifier, or a nonzero value if it is. If the argument is
EOF
, 0 is returned.
iscsymf
on a noncharacter argument other than EOF
is undefined. Do not assume that iscsymf
returns either 0 or 1.
#include <lctype.h> #include <stdio.h> #define IDMAX 40 main() { char id[IDMAX+1]; int i; char *text; char input[IDMAX]; puts("Enter any identifier (no more than 40 characters long)."); text = gets(input); /* Copy a C identifier from text to id. */ if (iscsymf(text[0])) { id[0] = text[0]; for (i = 1; i < IDMAX && iscsym(text[i]); ++i) id[i] = text[i]; id[i] = '0'; printf("The identifier is copied as %sn", id); } else puts("The first character of identifier is not acceptable.); }
iscsym
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.