[c++] 대소문자 변환
#include <iostream>
#include <cctype>
#include <string>

int main() {
    std::string str = "Hello, World!";
    for (char &c : str) {
        if (std::islower(c)) {
            c = std::toupper(c);
        } else if (std::isupper(c)) {
            c = std::tolower(c);
        }
    }
    std::cout << str << std::endl;
    return 0;
}

위 코드는 <cctype> 헤더의 std::toupperstd::tolower 함수를 사용하여 문자열의 대문자를 소문자로, 소문자를 대문자로 변환합니다.

예상 출력은 “hELLO, wORLD!”가 될 것입니다.