<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
You can write your code using transform:
string one;
string two;
cout << "\nPlayer One, please enter your move: ('p' for Paper, 'r' for Rock, '" << std::endl;
cin >> one;
std::transform(one.begin(), one.end(), one.begin(), ::tolower);
cout <<"\nPlayer Two, please enter your move: ('P' for Paper, 'R' for Rock, 'S'" << std::endl;
cin >> two;
std::transform(two.begin(), two.end(), two.begin(), ::tolower);
std::cout << "one=" << one << " ; two=" << two << std::endl;
The output may be as follows (for R, P):
Player One, please enter your move: ('p' for Paper, 'r' for Rock, '
R
Player Two, please enter your move: ('P' for Paper, 'R' for Rock, 'S'
P
one=r ; two=p
the transform is the right way to do it, i think, you just need to include the algorithm library
#include <ctype>
#include <algorithm>
#include <string>
std::transform(one.begin(), one.end(), one.begin(), ::tolower);
std::transform(two.begin(), two.end(), two.begin(), ::tolower);
You should store your character in variable and change the variable
#include <cctype>
#include <iostream>
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);
In header file " ctype.h" there are functions which supports case formatting
such as : tolower(var) formats text to lower case, toupper(var) formats text to upper case
Try:
#include <ctype>
tolower(char)
For a string input, you'll have to convert character by character:
char str[]="ONE TWO\n";
char c;
int i=0;
while (str[i])
{
c=str[i];
str[i] = (char) tolower(c); //I think it return an int, which you need to typecast to a char
i++;
}