Changing a capital letter (read from cin) to lower case?

前端 未结 5 1994
独厮守ぢ
独厮守ぢ 2021-01-29 08:13

i wanna change the capital cin to lower case for the input , for example if cin>> one one=R it should be r so it convert it automatically

<
5条回答
  •  北荒
    北荒 (楼主)
    2021-01-29 08:23

    You should store your character in variable and change the variable

    #include 
    #include 
    
    using namespace std;
    int main ()
    {
        char one{};
        char two{};
    cout << "\nPlayer One, please enter your move: ('p'  for Paper, 'r' for Rock, '$
    cin >> one;
    one = tolower(one);
    
    cout <<"\nPlayer Two, please enter your move: ('P' for Paper, 'R' for Rock, 'S'$
    cin >> two;
    one = tolower(two);
    

提交回复
热议问题