Created
February 23, 2022 15:54
-
-
Save lyf-is-coding/db4c44a4a69f0b8dedb3da6e8d6932fa to your computer and use it in GitHub Desktop.
C++ STL Uppercase/ Lowercase string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Input : abHDbGd | |
// Output : ABHDBGD - abhdbgd | |
#include <string> | |
std::string UppercaseStr(std::string str) | |
{ | |
int str_length = str.length(); | |
for (int i = 0; i < str_length; ++i) | |
str[i] = std::toupper(str[i]); | |
return str; | |
} | |
std::string LowercaseStr(std::string str) | |
{ | |
int str_length = str.length(); | |
for (int i = 0; i < str_length; ++i) | |
str[i] = std::tolower(str[i]); | |
return str; | |
} | |
std::cout << UppercaseStr("abHDbGd"); // ABHDBGD | |
std::cout << LowercaseStr("abHDbGd"); // abhdbgd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment