C++의 tolower() 함수
C++ tolower() 함수는 대문자 알파벳을 소문자 알파벳으로 변환합니다. 미리 정의된 함수입니다. ctype.h 헤더 파일. 전달된 문자가 대문자인 경우 tolower() 함수는 대문자 알파벳을 소문자 알파벳으로 변환합니다. 이 기능은 다른 소문자, 특수 기호 또는 숫자에는 영향을 주지 않습니다.
int tolower(int ch);
매개변수:
- ch: 소문자로 변환할 문자입니다.
반환 값: 이 함수는 ASCII 값을 반환합니다. 소문자 에 해당하는 ch.
C++에서는 int를 char로 형변환하는 작업이 다음과 같이 수행됩니다.
char c = (char) tolower('A'); 아래 프로그램은 C++의 tolower() 함수를 보여줍니다.
예시 1:
C++
// C++ program to demonstrate> // example of tolower() function.> > #include> using> namespace> std;> > int> main()> {> > > char> c => 'G'> ;> > > cout < < c < <> ' in lowercase is represented as = '> ;> > > // tolower() returns an int value there for typecasting> > // with char is required> > cout < < (> char> )> tolower> (c);> }> |
산출
G in lowercase is represented as = g
예시 2:
C++
// C++ program to convert a string to lowercase> // using tolower> #include> using> namespace> std;> > int> main()> {> > > // string to be converted to lowercase> > string s => 'GEEKSFORGEEKS'> ;> > > for> (> auto> & x : s) {> > x => tolower> (x);> > }> > > cout < < s;> > return> 0;> }> |
산출
geeksforgeeks
메모: tolower()에 전달된 문자가 다음 세 가지 중 하나인 경우
- 소문자
- 특수 기호
- 숫자
tolower()는 문자를 있는 그대로 반환합니다.
예시 3:
C++
// C++ program to demonstrate> // example of tolower() function.> #include> using> namespace> std;> > int> main() {> > > string s=> 'Geeks@123'> ;> > > for> (> auto> x:s){> > > cout < < (> char> )> tolower> (x);> > }> > > return> 0;> }> |
산출
geeks@123