C function ToLower, with ToUpper

Source: Internet
Author: User

ToLower convert uppercase to lowercase.

Non-alphabetic characters do not make processing.

This function is a bit special. He handles the characters rather than the strings.

The so-called inability to handle strings does not mean that he cannot handle strings, and when he handles them, the string must be handled one character at a time, and the string cannot be processed at once.

Usage: Commonly used to convert strings:

Example 1:

void ToUpper (char *string)
{
if (!string) return;
while (*string)
{
*string = ToUpper (*string);
string++;
}
}

void ToLower (char *string)
{
if (!string) return;
while (*string)
{
*string = ToLower (*string);
string++;
}
}

Example 2:

Used to do string comparisons

Case insensitive, converted to uppercase after comparison
Char C1 = ToUpper (*STR1);
char C2 = toupper (*STR2);
if (C1 > C2) return 1;
else if (C1 < C2) return-1;
else return StrCmp (str1+1, str2+1, sensitive); All the comparisons are judged first, and then all the uppercase letters are finally converted. Call the original comparison function again to process,

Example 3: Fill it up tomorrow,

C function ToLower, with ToUpper

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.