C++ 문자열 대문자로 변환

Jmnote (토론 | 기여)님의 2023년 12월 16일 (토) 22:07 판
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

C++ 문자열 대문자로 변환
C++ strtoupper() 구현
C++ uppercase() 구현
#include <iostream>
using namespace std;
string strtoupper(string str) {
    for(auto &c: str) c = toupper(c);
    return str;
}
int main() {
    cout << strtoupper("Hello World!") << endl; // HELLO WORLD!
}
#include <iostream>
#include <algorithm>
using namespace std;
string strtoupper(const string str) {
    string ret = str;
    transform(ret.begin(), ret.end(),ret.begin(), ::toupper);
    return ret;
}
int main() {
    cout << strtoupper("Hello World!") << endl; // HELLO WORLD!
}

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}