Chapter Contents

Previous

Next
isxdigit

isxdigit



Hexadecimal Digit Test

Portability: ISO/ANSI C conforming


SYNOPSIS
DESCRIPTION
RETURN VALUE
CAUTION
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <ctype.h>

int isxdigit(int c);


DESCRIPTION

isxdigit tests an integer value c to determine whether it is a hexadecimal digit (uppercase or lowercase).


RETURN VALUE

isxdigit returns 0 if the character is not a hexadecimal digit, or a nonzero value if it is. If the argument is EOF , 0 is returned.


CAUTION

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


EXAMPLE

#include <ctype.h>
#include <stdio.h>

#define IDLEN 40

main()
{
   char line[IDLEN];
   char id[IDLEN+1];
   char *text;
   int i;

   puts("Enter a string consisting of hexadecimal characters: ");
   text = gets(line);
      /* Copy from text to id.                                  */
   for (i = 0; i < IDLEN ; ++i) {
      if (isxdigit(text[i]))
         id[i] = text[i];
      else
         id[i] = '*';
   }
   id[i] = '\0';

      /* All nonhex characters have been replaced by '*'.       */
   puts("You have entered the following hexadecimal characters:");
   printf("%s\n", id);
}


RELATED FUNCTIONS

isdigit


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

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