From WikiChip
Difference between revisions of "c/ctype.h"
< c

m (Inject moved page Ctype.h - C to c/ctype.h)
m (Functions)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:<ctype.h> Header - C}}
+
{{c title|<ctype.h> Header}}{{C Standard Library}}
{{C Standard Library}}
 
 
 
 
The '''<ctype.h> header''' is part of the [[standard library]] of the [[C programming language]] that declares several functions useful for classifying and mapping characters.
 
The '''<ctype.h> header''' is part of the [[standard library]] of the [[C programming language]] that declares several functions useful for classifying and mapping characters.
  
Line 7: Line 5:
  
 
== Functions ==
 
== Functions ==
All functions in this header take a single argument of type '''int''' which should be representable as an '''unsigned char''' or be equal to the value of the macro '''[[EOF - C|EOF]]'''. All other values result in ''undefined behavior''.
+
All functions in this header take a single argument of type '''{{C|data types#Signed Integer Types|int}}''' which should be representable as an '''{{C|data types#Character Types|unsigned char}}''' or be equal to the value of the macro '''{{C|EOF}}'''. All other values result in ''[[undefined behavior]]''.
  
 
Functions in this header falls under two categories:
 
Functions in this header falls under two categories:
Line 18: Line 16:
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! Function Prototype !! Description !! Since
+
! Function Prototype     !! Description !! Since
 
|-
 
|-
| [[Ctype.h/isalnum - C|int isalnum(int c);]] || Checks if c is alphanumeric. || [[C89]]
+
| {{C|ctype.h/isalnum|int isalnum(int c);}} || Checks if c is alphanumeric. || {{C|C89}}
 
|-
 
|-
| [[Ctype.h/isalpha - C|int isalpha(int c);]] || Checks if c is alphabetic. || [[C89]]
+
| {{C|ctype.h/isalpha|int isalpha(int c);}} || Checks if c is alphabetic. || {{C|C89}}
 
|-
 
|-
| [[Ctype.h/isblank - C|int isblank(int c);]] || Checks if c is blank. || [[C99]]
+
| {{C|ctype.h/isblank|int isblank(int c);}} || Checks if c is blank. || [[C99]]
 
|-
 
|-
| [[Ctype.h/iscntrl - C|int iscntrl(int c);]] || Checks if c is a control character. || [[C89]]
+
| {{C|ctype.h/iscntrl|int iscntrl(int c);}} || Checks if c is a control character. || {{C|C89}}
 
|-
 
|-
| [[Ctype.h/isdigit - C|int isdigit(int c);]] || Checks if c is a decimal digit. || [[C89]]
+
| {{C|ctype.h/isdigit|int isdigit(int c);}} || Checks if c is a decimal digit. || {{C|C89}}
 
|-
 
|-
| [[Ctype.h/isgraph - C|int isgraph(int c);]] || Checks if c has a graphical representation. || [[C89]]
+
| {{C|ctype.h/isgraph|int isgraph(int c);}} || Checks if c has a graphical representation. || {{C|C89}}
 
|-
 
|-
| [[Ctype.h/islower - C|int islower(int c);]] || Checks if c is a lowercase letter. || [[C89]]
+
| {{C|ctype.h/islower|int islower(int c);}} || Checks if c is a lowercase letter. || {{C|C89}}
 
|-
 
|-
| [[Ctype.h/isprint - C|int isprint(int c);]] || Checks if c is printable. || [[C89]]
+
| {{C|ctype.h/isprint|int isprint(int c);}} || Checks if c is printable. || {{C|C89}}
 
|-
 
|-
| [[Ctype.h/ispunct - C|int ispunct(int c);]] || Checks if c is a punctuation character. || [[C89]]
+
| {{C|ctype.h/ispunct|int ispunct(int c);}} || Checks if c is a punctuation character. || {{C|C89}}
 
|-
 
|-
| [[Ctype.h/isspace - C|int isspace(int c);]] || Checks if c is a white-space character. || [[C89]]
+
| {{C|ctype.h/isspace|int isspace(int c);}} || Checks if c is a white-space character. || {{C|C89}}
 
|-
 
|-
| [[Ctype.h/isupper - C|int isupper(int c);]] || Checks if c is an uppercase letter. || [[C89]]
+
| {{C|ctype.h/isupper|int isupper(int c);}} || Checks if c is an uppercase letter. || {{C|C89}}
 
|-
 
|-
| [[Ctype.h/isxdigit - C|int isxdigit(int c);]] || Checks if c is a hexadecimal digit. || [[C89]]
+
| {{C|ctype.h/isxdigit|int isxdigit(int c);}} || Checks if c is a hexadecimal digit. || {{C|C89}}
 
|}
 
|}
  
Line 52: Line 50:
 
! Function Prototype !! Description !! Since
 
! Function Prototype !! Description !! Since
 
|-
 
|-
| [[Ctype.h/tolower - C|int tolower(int c);]] || Converts an uppercase letter to a corresponding lowercase letter. || [[C89]]
+
| {{C|ctype.h/tolower|int tolower(int c);}} || Converts an uppercase letter to a corresponding lowercase letter. || {{C|C89}}
 
|-
 
|-
| [[Ctype.h/toupper - C|int toupper(int c);]] || Converts a lowercase letter to a corresponding uppercase letter. || [[C89]]
+
| {{C|ctype.h/toupper|int toupper(int c);}} || Converts a lowercase letter to a corresponding uppercase letter. || {{C|C89}}
 
|-
 
|-
 
|}
 
|}
  
  
{{DEFAULTSORT:Ctype.h - C}}
+
{{DEFAULTSORT:ctype.h}}
[[Category:C standard library]]
+
[[Category:ctype.h]]
[[Category:Ctype.h - C]]
 

Latest revision as of 10:53, 7 January 2015

The <ctype.h> header is part of the standard library of the C programming language that declares several functions useful for classifying and mapping characters.

Some of the functions in this header are local-specific. That is, depending on the locale chosen, some functions behave slightly differently. The minimum locale that must be provided is the "C" locale.

Functions[edit]

All functions in this header take a single argument of type int which should be representable as an unsigned char or be equal to the value of the macro EOF. All other values result in undefined behavior.

Functions in this header falls under two categories:

Character classification functions[edit]

Function Prototype Description Since
int isalnum(int c); Checks if c is alphanumeric. C89
int isalpha(int c); Checks if c is alphabetic. C89
int isblank(int c); Checks if c is blank. C99
int iscntrl(int c); Checks if c is a control character. C89
int isdigit(int c); Checks if c is a decimal digit. C89
int isgraph(int c); Checks if c has a graphical representation. C89
int islower(int c); Checks if c is a lowercase letter. C89
int isprint(int c); Checks if c is printable. C89
int ispunct(int c); Checks if c is a punctuation character. C89
int isspace(int c); Checks if c is a white-space character. C89
int isupper(int c); Checks if c is an uppercase letter. C89
int isxdigit(int c); Checks if c is a hexadecimal digit. C89

Character case mapping functions[edit]

Two functions that deal with character case mapping is provided.

Function Prototype Description Since
int tolower(int c); Converts an uppercase letter to a corresponding lowercase letter. C89
int toupper(int c); Converts a lowercase letter to a corresponding uppercase letter. C89