Functions for character-case conversions in C + +

Source: Internet
Author: User
Tags uppercase letter

First Judge

If it is lowercase:

if (Islower (Str[i]))

The lowercase letter becomes the capital letter, the function is ToUpper
Str[i] = ToUpper (Str[i]);
Else

If it is an uppercase letter. The lowercase letter function is: ToLower
Str[i] = ToLower (Str[i]);


The detection capital letter is:isupper

The detection lowercase letter is: islower

Uppercase-------> Lowercase: ToLower

lowercase--------> Uppercase: ToUpper




Example

Code:

#include <iostream>
#include <cstdio>
#include <cstring>
#define MAXN 21
using namespace Std;
Char STR[MAXN];
int main ()
{
cin>>str;
for (int i = 0; i < strlen (str); i++)
{
if (Islower (Str[i]))
Str[i] = ToUpper (Str[i]);
else if (Isupper (Str[i]))
Str[i] = ToLower (Str[i]);
}
cout<<str;
return 0;
}



Functions for character-case conversions in C + +

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.