I want to convert a std::string
to lowercase. I am aware of the function tolower()
, however in the past I have had issues with this function and it
C++ doesn't have tolower
or toupper
methods implemented for std::string
, but it is available for char
. One can easily read each char of string, convert it into required case and put it back into string.
A sample code without using any third party library:
#include
int main(){
std::string str = std::string("How IS The Josh");
for(char &ch : str){
ch = std::tolower(ch);
}
std::cout<
For character based operation on string : For every character in string