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

Jmnote (토론 | 기여)님의 2018년 4월 14일 (토) 17:57 판 (새 문서: ==개요== ;C++ strtoupper() <source lang='cpp'> #include <iostream> using namespace std; string strtoupper(string str) { for(auto &c: str) c = toupper(c); return str; } i...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

C++ strtoupper()
#include <iostream>

using namespace std;

string strtoupper(string str) {
    for(auto &c: str) c = toupper(c);
    return str;
}

int main() {
    string str = "Hello World";
    string str2 = strtoupper(str);
    cout << str << endl; // Hello World
    cout << str2 << endl; // HELLO WORLD
}

2 같이 보기

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