Cctype
💻️/C++ publish: true aliases:
- null cssclass: null created: 2021-12-31 1945 updated: 2022-01-01 2151
The C Character Type Library
This header declares a set of functions to classify and transform individual characters.
isalpha( c )
true if alphabetic: a-z or A-Z
isalpha('x') // true
isalpha('6') // false
isalpha('!') // false
isdigit( c )
true if digit: 0-9.
isdigit('x') // false
isdigit('6') // true
isalnum( c )
Returns true if c is alphabetic or a numeric digit. Thus, returns true if either import.software.language.cpp.include-cctype (Private) or import.software.language.cpp.include-cctype (Private) would return true.
isspace( c )
true if whitespace.
isspace(' ') // true
isspace('\n') // true
isspace('x') // false
toupper( c )
Uppercase version
toupper('a') // A
toupper('A') // A
toupper('3') // 3
tolower( c )
Lowercase version
tolower('A') // a
tolower('a') // a
tolower('3') // 3
isblank()
Returns true if character c is a blank character. Blank characters include spaces and tabs.
isblank(myString[5]); // Returns true because that character is a space ' '.
isblank(myString[0]); // Returns false because 'H' is not blank.
isxdigit()
Returns true if c is a hexadecimal digit: 0-9, a-f, A-F.
isxdigit(myString[3]); // Returns true because '9' is a hexadecimal digit.
isxdigit(myString[1]); // Returns true because 'e' is a hexadecimal digit.
isxdigit(myString[6]); // Returns false because 'G' is not a hexadecimal digit.
ispunct()
Returns true if c is a punctuation character. Punctuation characters include: !"#$%&'()*+,-./:;<=>?@[\]^_{|}~
ispunct(myString[4]); // Returns true because '!' is a punctuation character.
ispunct(myString[6]); // Returns false because 'G' is not a punctuation character.
isprint()
Returns true if c is a printable character. Printable characters include alphanumeric, punctuation, and space characters.
iscntrl()
Returns true if c is a control character. Control characters are all characters that are not printable.
-
Tags:
-
Reference:
-
Related: