How to convert std::string to lower case?

后端 未结 26 2329
旧时难觅i
旧时难觅i 2020-11-22 00:01

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

26条回答
  •  生来不讨喜
    2020-11-22 00:27

    Try this function :)

    string toLowerCase(string str) {
    
        int str_len = str.length();
    
        string final_str = "";
    
        for(int i=0; i=65 && character<=92) {
    
                final_str += (character+32);
    
            } else {
    
                final_str += character;
    
            }
    
        }
    
        return final_str;
    
    }
    

提交回复
热议问题