Chapter Contents

Previous

Next
isalnum

isalnum



Alphanumeric Character Test

Portability: ISO/ANSI C conforming, UNIX compatible


SYNOPSIS
DESCRIPTION
RETURN VALUE
CAUTIONS
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <ctype.h>

int isalnum(int c);


DESCRIPTION

isalnum tests an integer value to determine whether it is an alphabetic (uppercase or lowercase) or numeric character.


RETURN VALUE

isalnum returns 0 if the character is not alphanumeric, or a nonzero value if it is alphanumeric. If the argument is EOF , 0 is returned.


CAUTIONS

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


EXAMPLE

#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 of characters (40 at most).");
   text = gets(input);

   puts("Initial alphanumeric characters you entered are:");
   for (i = 0; i < MAXLEN && isalnum(text[i]); i++)  {
      id[i] = text[i];
      putc(id[i]);
   }

   id[i] = '\0';
   putc('\n');
}


RELATED FUNCTIONS

isalpha , isdigit


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

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