Ctype.h Library functions----character manipulation functions

Source: Internet
Author: User
Tags printable characters

When used in C + +: #include <cctype>

Character Judgment function

1. isalnum function--Determines whether it is an English letter or a numeric character, if so, returns a value other than 0, or 0 if not.

Function parameter: can be a character or an integer number.

Use case: if (isalnum (CH)!=0)

Common in Windows and Linux

2, Isalpha function---Determine whether it is an English letter, if it is, then return a non-0 value, if not, then return 0.

Function parameter: can be a character or an integer number.

Use case: if (isalpha (CH)!=0)

3, Isascii function----Determine whether the ASCII code is located between 0~127, if it is, then return a non-0 value, if not, then return 0/

Function parameter: can be a character or an integer number.

Use case: if (ISASCII (CH)!=0)

4, Iscntrl function----Determine whether the control character (ASCII code is 0~31 and 0X7F//ASCII code 127), if it is, then return a non-0 value, if not, then return 0.

Function parameter: can be a character or an integer number.

Use case: if (Iscntrl (CH)!=0)

5, IsDigit function----Determine whether it is a numeric character (ASCII code is 48~57), if it is, then return a non-0 value, if not, then return 0

Function parameter: can be a character or an integer number.

Use case: if (isdigit (CH)!=0)

6, the Isgraph function---to judge in addition to the empty printable character (if a space, return 0). If yes, returns a non-0 value, or 0 if not.

Function parameter: can be a character or an integer number.

Use case: if (isgraph (CH)!=0)

7, Islower function---to determine whether it is a lowercase English letter. If so, returns a value other than 0, or 0 if not.

Function parameter: can be a character or an integer number.

Use case: if (islower (CH)!=0)

8, ispunct function---judge whether it is punctuation. If so, returns a value other than 0, or 0 if not.

Function parameter: can be a character or an integer number.

Use case: if (ispunct (CH)!=0)

9. The Isprint function---determine printable characters including spaces. If so, returns a value other than 0, or 0 if not.

Function parameter: can be a character or an integer number.

Use case: if (isprint (CH)!=0)

10. The Isspace function---determine if it is a blank character. If so, returns a value other than 0, or 0 if not.

Function parameter: can be a character or an integer number.

Use case: if (isspace (CH)!=0)

11. The Isxdigit function---determine if it is a hexadecimal character (emphasis). If so, returns a value other than 0, or 0 if not.

Function parameter: can be a character or an integer number.

Use case: if (isxdigit (CH)!=0)

Character Conversion functions

1. The ToLower function---converts uppercase letters to lowercase English letters. If CH is an uppercase English letter, the lowercase English letter is returned, and if not, the original character is returned.

Function parameter: can be a character or an integer number.

Use case: ToLower (CH);

2. The ToUpper function---Converts lowercase english letters to uppercase English letters. If CH is a lowercase English letter, the uppercase English letter is returned, and if not, the original character is returned.

Function parameter: can be a character or an integer number.

Use case: ToUpper (CH);

3. The TOASCII function---Converts the character to the corresponding ASCII code, and the digits outside the lower seven bits will be cleared

Function arguments: Characters

Use case: Toascii (CH); (only a single character, if it is a string, returns the ASCII code of the first character)

Ctype.h Library functions----character manipulation functions

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.