📜  字符串到上层 c++ 代码示例

📅  最后修改于: 2022-03-11 14:44:57.149000             🧑  作者: Mango

代码示例4
#include 
#include 
using namespace std;

int main()
{
    char letter;

    cout << "You will be asked to enter a character.";
    cout << "\nIf it is a lowercase character, it will be converted to uppercase.";
    cout << "\n\nEnter a character. Press . to stop: ";

    cin >> letter;

    if(islower(letter))
    {
        letter = isupper(letter);
        cout << letter;
    }

    while(letter != '.')
    {
        cout << "\n\nEnter a character. Press . to stop: ";
        cin >> letter;

        if(islower(letter))
        {
            letter = toupper(letter);
            cout << letter;
        }
    }

    return 0;
}