Convert a String In C++ To Upper Case

后端 未结 30 1911
一个人的身影
一个人的身影 2020-11-22 05:25

How could one convert a string to upper case. The examples I have found from googling only have to deal with chars.

30条回答
  •  滥情空心
    2020-11-22 06:11

    Here is the latest code with C++11

    std::string cmd = "Hello World";
    for_each(cmd.begin(), cmd.end(), [](char& in){ in = ::toupper(in); });
    

提交回复
热议问题