Is there a way to push all the element in the std::string variable to uppercase like java str.toUpperCase()?

std::cout << "Enter a name for player 1" << std::endl;
std::cin >> p1;
Player* player1 = new Player(p1);
std::cout << std::endl;

std::string p2;
std::cout << "Enter a name for player 2" << std::endl;
std::cin >> p2;
Player* player2 = new Player(p2);
std::cout << std::endl;

Input:

Lando
Charles

Goal for p1 = LANDO

Goal for p2 = CHARLES

PS: Is it also possible to store it in two other strings so it can be further compare as such:

if(p1.compare(newStr1){
...

}

if(p2.compare(newStr2){
...

}

0 Answers