코-딩/C & C++

C & C++ - char* 을 toupper/tolower로 변환하기

ㅋㅂㅋ 2022. 10. 12. 17:29

아스키 코드표에 기반한 숫자로 인식한다. tolower = int tolower(int c);

 

char* toUpperOrToLower(char* change) {

 

    int length = (int)strlen(change);

    for(int i=0; i<length; ++i){

        //change[i] = tolower(*(change + i));

       change[i] = toupper(*(change + i));

    }

    return change;

 

}

 

lower/upper 중에 하고 싶은 변환을 넣으면 된다.

 

(string 은 char*으로 변환이 필요하다.)

 

출처 & 참고

 

[C언어/C++] tolower, toupper 대문자 소문자 변경

안녕하세요. BlockDMask 입니다. 오늘은 C언어, C++에서 알파벳을 소문자는 대문자로, 대문자는 소문자로 변경해주는 tolower, toupper 함수에 대해서 알아보려고 합니다. <목차> 1. toupper, tolower 함수 원형

blockdmask.tistory.com