C++ strtolower()

1 개요[ | ]

C++ strtolower()
C++
Copy
#include <iostream>
using namespace std;
string strtolower(string str) {
    for(auto &c: str) c = tolower(c);
    return str;
}
int main() {
    cout << strtolower("Hello World!") << endl; // hello world!
}
Loading
C++
Copy
#include <iostream>
#include <algorithm> // transform
using namespace std;
string strtolower(const string str) {
    string ret = str;
    transform(ret.begin(), ret.end(),ret.begin(), ::tolower);
    return ret;
}
int main() {
    cout << strtolower("Hello World!") << endl; // hello world!
}
Loading

2 같이 보기[ | ]