Syntax
#include <ctype.h> int _toascii(int c); int _tolower(int c); int _toupper(int c);Description
_tolower converts c to the corresponding lowercase letter, if possible.
_toupper converts c to the corresponding uppercase letter, if possible.
Important Use _tolower and _toupper only when you know that c is uppercase A to Z or lowercase a to z, respectively. Otherwise the results are undefined. These functions are not affected by the current locale.
These are all macros, and do not correctly handle arguments with side effects.
For portability, use the tolower and toupper functions defined by the ANSI/ISO standard, instead of the _tolower and _toupper macros.
This example prints four sets of characters. The first set is the ASCII characters having graphic images, which range from 0x21 through 0x7e. The second set takes integers 0x7f21 through 0x7f7e and applies the _toascii macro to them, yielding the same set of printable characters. The third set is the characters with all lowercase letters converted to uppercase. The fourth set is the characters with all uppercase letters converted to lowercase.
#include <stdio.h> #include <ctype.h> int main(void) { int ch; printf("Characters 0x01 to 0x03, and integers 0x7f01 to 0x7f03 mapped to\n"); printf("ASCII by _toascii() both yield the same graphic characters.\n\n"); for (ch = 0x01; ch <= 0x03; ch++) { printf("char 0x%.4X: %c ", ch, ch); printf("char _toascii(0x%.4X): %c\n", ch+0x7f00, ch+0x7f00); } printf("\nCharacters A, B and C converted to lowercase and\n"); printf("Characters a, b and c converted to uppercase.\n\n"); for (ch = 0x41; ch <= 0x43; ch++) { printf("_tolower(%c) = %c ", ch, _tolower(ch)); printf("_toupper(%c) = %c\n", ch+0x20, _toupper(ch+0x20)); } return 0; /**************************************************************************** The output should be: Characters 0x01 to 0x03, and integers 0x7f01 to 0x7f03 mapped to ASCII by _toascii() both yield the same graphic characters. char 0x0001: char toascii(0x7F01): char 0x0002: char toascii(0x7F02): char 0x0003: char toascii(0x7F03): Characters A, B and C converted to lowercase and Characters a, b and c converted to uppercase. _tolower(A) = a _toupper(a) = A _tolower(B) = b _toupper(b) = B _tolower(C) = c _toupper(c) = C ****************************************************************************/ }Related Information