test for a character in the range 0 to 127
#include <ctype.h> int isascii( int c ); int __isascii( int c );
The isascii() function tests for a character in the range from 0 to 127.
The __isascii() function is identical to isascii(). Use __isascii() for ANSI/ISO naming conventions.
A nonzero value when the character is in the range 0 to 127; otherwise, zero.
#include <stdio.h>
#include <ctype.h>
char chars[] = {'A', 0x80, 'Z'};
#define SIZE sizeof( chars ) / sizeof( char )
void main()
{
int i;
for( i = 0; i < SIZE; i++ ) {
printf( "Char %c is %san ASCII character\n",
chars[i],
( isascii( chars[i] ) ) ? "" : "not " );
}
}
produces the output:
Char A is an ASCII character Char is not an ASCII character Char Z is an ASCII character
WATCOM
__isascii() conforms to ANSI/ISO naming conventions.
| Safety: | |
|---|---|
| Interrupt handler | Yes |
| Signal handler | Yes |
| Thread | Yes |
isalpha(), isalnum(), iscntrl(), isdigit(), isgraph(), islower(), isprint(), ispunct(), isspace(), isupper(), isxdigit()