How to convert std::string to lower case?

后端 未结 26 1708
旧时难觅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:44

    Another approach using range based for loop with reference variable

    string test = "Hello World";
    for(auto& c : test)
    {
       c = tolower(c);
    }
    
    cout<

提交回复
热议问题