C Standard Library Reference Guide series (2) ctype. h

Source: Internet
Author: User
Tags control characters printable characters uppercase letter

Http://www.acm.uiuc.edu/webmonkeys/book/c_guide/2.2.html.

Author: Eric Huss

Chinese translator: Liu jinhong poechant

Copyright Disclaimer: the original text in this article is copyrighted by Eric Huss, and the Chinese translation is copyrighted by poechant. Reprinted please indicate from "LIU Da's csdn blog": http://blog.csdn.net/poechant

2. ctype. h

Character header files are used to test characters and convert characters. A control character that references another character is not a printable character set. In the ASCII character set, all characters 0x0 to 0x1 F and 0x7f (delete key) are control characters, and the printable characters are from 0x20 (Space) to 0x7e (Tilde ).

Function:

Isalnum ();

Isalpha ();

Iscntrl ();

Isdigit ();

Isgraph ();

Islower ();

Isprint ();

Ispunct ();

Isspace ();

Isupper ();

Isxdigit ();

Tolower ();

Toupper ();

2.1. Is... Functions

Statement:

Int isalnum (intCharacter);

Int isalpha (intCharacter);

Int iscntrl (intCharacter);

Int isdigit (intCharacter);

Int isgraph (intCharacter);

Int islower (intCharacter);

Int isprint (intCharacter);

Int ispunct (intCharacter);

Int isspace (intCharacter);

Int isupper (intCharacter);

Int isxdigit (intCharacter);

Like "is ..." And return a non-zero value (true) when the character meets the conditions ). If not, 0 (false) is returned ).

Condition:

Isalnum

English letters (A to Z, or A to Z), or Arabic numerals (0 to 9)

Isalpha

English letters (A to Z, or A to Z)

Iscntrl

Control characters (0x00 to 0x1f, or 0x7f)

Isdigit

Arabic numerals (0 to 9)

Isgraph

Any printable characters except spaces (0x21 to 0x7e)

Islower

Lowercase letters (A to Z)

Isprint

Printable characters (0x20 to 0x7e)

Ispunct

Punctuation Marks (printable characters except space and album)

Isspace

Blank characters (space, tab, carriage return, line break, vertical tab, form feed)

Isupper

Uppercase letters (A to Z)

Isxdigit

Hexadecimal number (0 to 9, A to F, or A to F)

2.2. to... Functions

Statement:

Int tolower (intCharacter);

Int toupper (intCharacter);

Like "..." To convert a single character. If a character Meets the appropriate conditions, it will be converted by this function. Otherwise, the function returns the original character.

Condition:

Tolower

If it is an upper-case letter, it is converted to a lower-case letter.

Toupper

If it is a lowercase letter, it is converted to the corresponding uppercase letter.

Instance:

# Include <ctype. h>

# Include <stdio. h>

# Include <string. h>

Int main (void)

{

Int loop;

Char string [] = "this is a test ";

For (loop = 0; loop <strlen (string); loop ++)

String [loop] = tolower (string [loop]);

Printf ("% s \ n", string );

Return 0;

}

(1) assert. HC standard Library Reference Guide series (2) ctype. HC standard Library Reference Guide series (3) errno. HC standard Library Reference Guide series (4) float. HC standard Library Reference Guide series (5) limits. HC standard Library Reference Guide series (6) locale. HC standard Library Reference Guide series (7) math. HC standard Library Reference Guide series (8) setjmp. HC standard Library Reference Guide series translations (9) signal. HC standard Library Reference Guide series translations (10) stdarg. HC standard Library Reference Guide series (11) stddef. HC standard Library Reference Guide series translations (12) stdio. H ()

Copyright Disclaimer: the original text in this article is copyrighted by Eric Huss, and the Chinese translation is copyrighted by poechant. Reprinted please indicate from "LIU Da's csdn blog": http://blog.csdn.net/poechant

-

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.