문자열의 문자를 대문자 또는 소문자로 변환할 때 toupper와 tolower 함수를 사용한다. <cctype> 헤더 파일에 포함되어 있다.
#include <cctype>
int main() {
char c = 'a'; // 소문자 'a'
char upper = toupper(c); // 'A'로 변환
std::cout << upper; // 출력: A
return 0;
}
#include <cctype>
int main() {
char c = 'A'; // 대문자 'A'
char lower = tolower(c); // 'a'로 변환
std::cout << lower; // 출력: a
return 0;
}