C++字符串大写字母转小写字母

#include <iostream>
#include <stdio.h>

using namespace std;

char* Capital_to_Small(char* str)
{
    char* temp = str;
    int len = strlen(temp);
    for (int i = 0; i < len; i++)
    {

        if (temp[i] >= 'A' && temp[i]<='Z')
        {
            temp[i] = temp[i] + 32;
        }
    }

    return str;
}

int main()
{
    char s[_MAX_PATH];
    cin >> s;
    Capital_to_Small(s);
    cout << s;

    getchar();

    return 0;
}

 

posted @ 2020-03-26 14:36  strive-sun  阅读(1917)  评论(0编辑  收藏  举报