[C++] stolower()

#include <algorithm>
#include <string>
using namespace std; string data = "Abc"; 
transform(data.begin(), data.end(), data.begin(), ::tolower);

OR

#include
#include

using namespace std;
string &stolower(string &s)
{
    for(int i=0;i<s.length();i++)
    {
        s[i]=tolower(s[i]);
    }
    return s;
}
int main()
{
    string s="ABC";
    cout<<stolower(s);
    return 0;
}

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *