[Linux C] character test function

Source: Internet
Author: User

I. Overview

The character test function is included in the header file <ctype. h>

These are macro definitions, not real functions.


1) isalnum test whether the character is an English letter or number

#include <stdio.h>#include <ctype.h>int main(){   char str[]="12#$%sdfsfsf";   int i;   for(i=0;str[i]!=0;++i)if(isalnum(str[i]))printf("%c is an alphanumberic character\n",str[i]);   return 0;}

2) isalpha test for English letters

#include <stdio.h>#include <ctype.h>int main(){   char str[]="12#$%sdfsfsf";   int i;   for(i=0;str[i]!=0;++i)if(isalpha(str[i]))printf("%c is an alpha character\n",str[i]);   return 0;}

3) isascii test whether it is an ASCII character

#include <stdio.h>#include <ctype.h>int main(){   int i;   for(i=125;i<130;++i)if(isascii(i))printf("%d is an ascii character\n",i);        elseprintf("%d is not an ascii character\n",i);   return 0;}

4) The isblank test character is a white space character

5) iscntrl (c) test whether it is an ASCII control code, that is, whether it is between 0 and 31.

6) isdigit test whether it is Arabic numerals

7) isgraph test whether it is a printable character, not a blank character (see 10)

8) islower test whether it is a lowercase English letter

9) isprint test whether the character is printable similar to isgraph

10) isspace test whether the characters are white spaces '', '\ t',' \ n', '\ F', and' \ V'

11) ispunct test whether it is a punctuation or special symbol

12) isupper test whether it is a capital English letter

13) isxdigit test whether the character is a hexadecimal number 0 1 2 2 3 4 5 6 7 8 9 A B C D E F

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.