The method of using C language to judge the case of English characters _c language

Source: Internet
Author: User
Tags lowercase uppercase character

C language Isupper () function: To determine whether the character is uppercase English letters
header file:

 #include <ctype.h>

To define a function:

int isupper (int c);

Function Description: Check whether the parameter C is an uppercase English letter.

Return value: If parameter C is an uppercase English letter, returns a non 0, otherwise returns 0.

Additional description: This is a macro definition, not a true function.

Example: Find characters in the string str that are uppercase English letters.

#include <ctype.h>
Main () {
  char str[] = "123c@ #FDsP [E?";
  int i;
  for (i = 0; Str[i]!= 0; i++)
    if (Isupper (str[i)))
      printf ("%c be an uppercase character\n", str[i));

Execution results:

F is a uppercase character
D is a uppercase character
P is a uppercase character

C language Islower () function: To determine whether a character is a lowercase letter
header file:

#include <ctype.h>

Islower () is used to determine whether a character is a lowercase letter, and its prototype is:

  int islower (int c);

"Parameter" C is the character you want to detect.

return value if parameter C is a lowercase English letter, returns a value other than 0, otherwise returns 0.

Note that this is a macro definition, not a true function.

"Instance" determines which of the STR strings are lowercase letters.

#include <ctype.h>
Main () {
  char str[] = "123@ #FDsP [E?";
  int i;
  for (i = 0; Str[i]!= 0; i++)
    if (Islower (str[i)))
      printf ("%c be a lower-case character\n", Str[i]);

Output results:

C is a lower-case character
S. A lower-case character
E is a lower-case character

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.