Character judgments and character mappings

Source: Internet
Author: User

C language provides a series of functions for character judgment and character mapping

1. Character Judgment function

Return value: If the function argument is a character type that is judged, returns true, otherwise false

A, ISALNMU () numbers or letters

B, Isalpha () Letter

C, Isblank () standard white space characters (spaces, horizontal tabs, or line breaks)

D, Iscntrl () control characters (e.g. Ctrl + B)

E, Isupper () capital letters

F, islower () lowercase letters

G, Isgraph () all printable characters except for whitespace

H, Isprint () all printable characters

I, ispunct () punctuation

J, Isspace () white space characters: spaces, newline, paper, carriage return, vertical tab, Horizontal tab, or locally defined characters

K, isdigit () Arabic numerals

L, Isxdigit () hexadecimal numeric characters

2. Character mapping function

A, ToLower () If the argument is an uppercase character, returns the corresponding lowercase character;

B, ToUpper () If the argument is lowercase, the corresponding uppercase character is returned, and no person returns the original characters

Test program

#include <stdio.h>
#include <ctype.h>

#define SPACE '

int Test ()
{
int a = 0;
Double tep;
printf ("&&&&&&\n");
while (scanf ("%lf", &tep) = = 1)
{
a++;
}
printf ("A =%d\n", a);
}

int Test1 ()
{
Char ch;
ch = getchar ();
while ((ch = getchar ())! = ' \ n ')
{
if (isalnum (CH))
Putchar (ch + 1);
Else
Putchar (CH);

ch = getchar ();
}
Putchar (CH);

return 0;
}

int main ()
{
int ret = 111;
char *str_zebos = NULL;

Str_zebos = (char *) malloc (* sizeof (char));
printf ("%d\n", * sizeof (char));

printf ("ret =%d\n", ret = Test ());
Test1 ();

return 0;
}

Character judgments and character mappings

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.