[c++] toupper/tolower 대소문자 변환하기

corncheese·2021년 7월 14일
0

c++STL

목록 보기
2/4

문자열을 비교할 때 대문자또는 소문자로 통일해야 편리할때 사용한다.

#include <iostream>
#include <algorithm>

using namespace std;

int main(){

    string a;
    cin >> a;

    transform(a.begin(), a.end(), a.begin(), ::toupper);
    transform(a.begin(), a.end(), a.begin(), ::tolower);
    
    char A;
    cin >> A;
    
    A = toupper(A);
    A = tolower(A);
}
  • transform 함수
    STL *algorithm 라이브러리를 includeg해야 가능하다.

  • transform 함수의 인자 전달 순서
    transform(복사할 문자열의 시작점, 복사할 문자열의 종료점, 복사될 문자열의 시작점, toupper/tolower)

  • 대문자변환시 toupper / 소문자변환시 tolower

0개의 댓글