나의 작은 valley
[C언어] ctype.h 문자 분류 함수 본문
728x90
https://www.tutorialspoint.com/c_standard_library/ctype_h.htm
C Library - <ctype.h>
C Library - The ctype.h header file of the C Standard Library declares several functions that are useful for testing and mapping characters. All the functions accepts int as a parameter, whose value must be EOF or representable as an unsigned char. All the
www.tutorialspoint.com
위의 사이트에서 ctype.h 라이브러리에 있는 다양한 문자 분류 함수들을 볼 수 있다.
그 중 toupper()와 islower()을 사용하여 대문자를 소문자로, 소문자를 대문자로 바꾸는 코드를 짜보았다.
#include <stdio.h> // getchar(), putchar()
#include <ctype.h>
int main()
{
char ch;
while ((ch= getchar()) != '\n')
{
if (islower(ch)) // && == and, 논리연산자
ch = toupper(ch);
else if (isupper(ch))
ch = tolower(ch);
putchar(ch);
}
putchar(ch);
return 0;
}
728x90
'Computer Science > [C언어] 문법 정리' 카테고리의 다른 글
[C언어] 조건연산자 (0) | 2022.09.15 |
---|---|
[C언어] 논리 연산자 Logical operators (0) | 2022.09.15 |
[C언어] getchar()함수, putchar()함수 (0) | 2022.09.14 |
[C언어] 분기문 if, 다중 선택(else if) (0) | 2022.09.14 |
[C언어] 배열, 루프에 대한 자세한 이해, 런타임 에러 (0) | 2022.09.13 |
Comments