You can use the toupper() and tolower() functions from the <cctype> header to convert a string to uppercase or lowercase.
Here's an example:
#include <iostream>
#include <string>
#include <cctype>
int main() {
std::string userInput;
std::cout << "Enter a string: ";
std::getline(std::cin, userInput);
// Convert to uppercase
for (char& c : userInput) {
c = std::toupper(c);
}
std::cout << "Uppercase string: " << userInput << std::endl;
// Convert to lowercase
for (char& c : userInput) {
c = std::tolower(c);
}
std::cout << "Lowercase string: " << userInput << std::endl;
return 0;
}