
📌 매뉴얼 (Linux)
SYNOPSIS
int isprint(int c);
: 함수 프로토타입
DESCRIPTION
isprint()
checks for any printable character including space.
: 띄어쓰기를 포함한 인쇄 가능한 문자가 있는지 확인한다
RETURN VALUE
The values returned are nonzero if the character c falls into the tested class, and zero if
not.
: 반환값은 조건에 만족하지 않으면 0이고, 만족하면 0이 아닌 값이다
NOTES
The standards require that the argument c for these functions is either EOF or a value that is
representable in the type unsigned char. If the argument c is of type char, it must be cast
to unsigned char, as in the following example:
char c;
...
res = toupper((unsigned char) c);
This is necessary because char may be the equivalent of signed char, in which case a byte
where the top bit is set would be sign extended when converting to int, yielding a value that
is outside the range of unsigned char.
The details of what characters belong to which class depend on the locale. For example, isup‐
per() will not recognize an A-umlaut (Ä) as an uppercase letter in the default C locale.
📌 작성 코드
int do_isprint(int d)
{
if (d >= 32 && d <= 126)
return (1);
else
return (0);
}
📌 코드 리뷰
printable 한, 즉 출력가능한 문자들은 ASCII 표 상에서 32 (띄어쓰기) 부터 126 (~) 까지 이다.
따라서 해당 범위에 있으면 isprint 함수에 의해 1을 반환하고 아니면 0을 반환하도록 한다.
'프로그래밍 > C' 카테고리의 다른 글
[library] strlcpy 구현하기 (0) | 2024.03.19 |
---|---|
[library] strlen 구현하기 (0) | 2024.03.18 |
[library] isascii 구현하기 (0) | 2024.03.18 |
[study] Linked List (연결 리스트) (0) | 2024.03.14 |
[library] isalnum 구현하기 (0) | 2024.03.13 |