_IS_xxx                           <CTYPE.H>
 =========

Bit settings in the _ctype[] used by the
is... character macros.

  Name    | Meaning
 ---------+----------------------------------
  _IS_SP  | Is space
  _IS_DIG | Is digit
  _IS_UPP | Is uppercase
  _IS_LOW | Is lowercase
  _IS_HEX | [A-F] or [a-f]
  _IS_CTL | Control
  _IS_PUN | Punctuation


========= CTYPE.H ========= _ftolower _ftoupper isalnum isalpha isascii iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit toascii tolower toupper Constants, datatypes and global variables ========================================== _IS_CTL _IS_DIG _IS_HEX _IS_LOW _IS_PUN _IS_SP _IS_UPP See Also ======== List of all Header files
_ctype <CTYPE.H> ======== Array of character-attribute information indexed by ASCII value + 1. Declaration: extern char _ctype[] Each entry is a set of _IS_... bits describing the character. See Also: is... macros List of all global variables
============================ isalnum, isalpha, isascii, iscntrl, isdigit, isgraph, islower, isprint, ispunct, <all in CTYPE.H> isspace, isupper, isxdigit ============================ Character classification macros Declarations: * int isalnum(int c); * int islower(int c); * int isalpha(int c); * int isprint(int c); * int isascii(int c); * int ispunct(int c); * int iscntrl(int c); * int isspace(int c); * int isdigit(int c); * int isupper(int c); * int isgraph(int c); * int isxdigit(int c); Remarks: The is... macros classify ASCII coded integer values by table lookup. Each macro is a predicate that returns a non-zero value for true and 0 for false. isascii is defined on all integer values. The other is... macros are defined only when isascii(c) is true or c is EOF. You can make each macro available as a function by undefining it (with #undef). Return Value: The is... macros return a non-zero value on success. For each macro, success is defined as follows: * isalpha: c is a letter (A to Z or a to z) * isascii: the low order byte of c is in the range 0 to 127 (0x00--0x7F) * iscntrl: c is a delete character or ordinary control character (0x7F or 0x00 to 0x1F) * isdigit: c is a digit (0 to 9) * isgraph: c is a printing character, like isprint, except that a space character is excluded * islower: c is a lowercase letter (a to z) * isprint: c is a printing character (0x20 to 0x7E) * ispunct: c is a punctuation character (iscntrl or isspace) * isspace: c is a space, tab, carriage return, new line, vertical tab, or formfeed (0x09 to 0x0D, 0x20) * isupper: c is an uppercase letter (A to Z) * isxdigit: c is a hexadecimal digit (0 to 9, A to F, a to f) Portability (all is... macros except isascii) + DOS + UNIX + Windows + ANSI C + C++ Only + | Yes | Yes | Yes | Yes | | +-----+------+---------+--------+----------+ isascii: + DOS + UNIX + Windows + ANSI C + C++ Only + | Yes | Yes | Yes | | | +-----+------+---------+--------+----------+
========= toascii <CTYPE.H> ========= Translates characters to ASCII format Declaration: int toascii(int c); Remarks: toascii is a macro that converts the integer c to ASCII by clearing all but the lower 7 bits. This gives a value in the range 0 to 127. Return Value: toascii returns the converted value of c. Portability: + DOS + UNIX + Windows + ANSI C + C++ Only + | Yes | Yes | Yes | | | +-----+------+---------+--------+----------+ Example: #include <stdio.h> #include <ctype.h> int main(void) { int number, result; number = 511; result = toascii(number); printf("%d %d\n", number, result); return 0; }
=========== _tolower, tolower <CTYPE.H> =========== Translate characters to lowercase Declaration: * int tolower(int ch); * int _tolower(int ch); Remarks: * tolower is a function that converts an integer ch (in the range EOF to 255) to its lowercase value (a to z; if it was uppercase, A to Z). All others are left unchanged. * _tolower is a macro that does the same conversion as tolower, except that it should be used ONLY when ch is known to be uppercase (A-Z). To use _tolower, you must include CTYPE.H. Return Value: * If ch is uppercase, _tolower and tolower return its converted value. * If ch is not uppercase, * tolower returns ch unchanged. * _tolower's result is undefined. Portability + DOS + UNIX + Windows + ANSI C + C++ Only + _tolower | Yes | Yes | Yes | | | tolower | Yes | Yes | Yes | Yes | | +-----+------+---------+--------+----------+ Examples: _tolower example tolower example
tolower example ================= #include <string.h> #include <stdio.h> #include <ctype.h> int main(void) { int length, i; char *string = "THIS IS A STRING"; length = strlen(string); for (i=0; i<length; i++) { string[i] = tolower(string[i]); } printf("%s\n",string); return 0; }
_tolower example ================== /* _tolower example */ #include <string.h> #include <stdio.h> #include <ctype.h> int main(void) { int length, i; char *string = "THIS IS A STRING."; length = strlen(string); for (i = 0; i < length; i++) { if ((string[i] >= 'A') && (string[i] <= 'Z')){ string[i] = _tolower(string[i]); } } printf("%s\n",string); return 0; }
=========== _toupper, toupper <CTYPE.H> =========== Translate characters to uppercase Declaration: * int toupper(int ch); * int _toupper(int ch); Remarks * toupper is a function that converts an integer ch (in the range EOF to 255) to its uppercase value (A to Z; if it was lowercase, a to z). All others are left unchanged. * _toupper is a macro that does the same conversion as toupper, except that it should be used only when ch is known to be lowercase (a to z). To use _toupper, you must include CTYPE.H. Return Value: * If ch is lowercase, _toupper and toupper return its converted value. * If ch is not lowercase, * toupper returns ch unchanged. * _toupper's result is undefined. Portability: + DOS + UNIX + Windows + ANSI C + C++ Only + _toupper | Yes | Yes | Yes | | | toupper | Yes | Yes | Yes | Yes | | +-----+------+---------+--------+----------+ Examples: _toupper example toupper example
toupper example ================= #include <string.h> #include <stdio.h> #include <ctype.h> int main(void) { int length, i; char *string = "this is a string"; length = strlen(string); for (i=0; i<length; i++) { string[i] = toupper(string[i]); } printf("%s\n",string); return 0; }
_toupper example ================== /* _toupper example */ #include <string.h> #include <stdio.h> #include <ctype.h> int main(void) { int length, i; char *string = "this is a string."; length = strlen(string); for (i = 0; i < length; i++) { if ((string[i] >= 'a') && (string[i] <= 'z')){ string[i] = _toupper(string[i]); } } printf("%s\n",string); return 0; }