Chapter Contents

Previous

Next
iscsymf

iscsymf



Test for Valid C Identifier Initial Symbol

Portability: SAS/C extension


SYNOPSIS
DESCRIPTION
RETURN VALUE
CAUTION
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <lctype.h>

int iscsymf(int c);


DESCRIPTION

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.


RETURN VALUE

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.


CAUTION

The effect of iscsymf on a noncharacter argument other than EOF is undefined. Do not assume that iscsymf returns either 0 or 1.


EXAMPLE

#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 %s\n", id);
   }
   else
      puts("The first character of identifier is not acceptable.);
}


RELATED FUNCTIONS

iscsym


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.